ASP Practical Library

xiaoxiao2021-03-06  102

<%

'Judging whether the file name is legal

Function isFileName (AfileName)

DIM SERRORSTR, INAMELENGTH, I

IsFileName = TRUE

SERRORSTR = Array ("/", "/", ":" * ","? "," "" "," <","> "," | ")

INameLength = LEN (AfileName)

IF inamelength <1 or inamelength = null dam

IsFileName = false

Else

For i = 0 TO 8

IF INSTR (AfileName, SERRORSTR (i)) THEN

IsFileName = false

END IF

NEXT

END IF

END FUNCTION

'Continuous carriage return and spaces of the character serial tail

Function Trimvbcrlf (STR)

Trimvbcrlf = RTRIMVBCRLF (Ltrimvbcrlf (STR))

END FUNCTION

'Continuous carriage return and spaces of the beginning of the string

Function LTRIMVBCRLF (STR)

Dim Pos, Isblankchar

POS = 1

Isblankchar = True

While isblankchar

IF MID (STR, POS, 1) = "" "" "

POS = POS 1

Elseif MID (Str, POS, 2) = vbcrlf then

POS = POS 2

Else

Isblankchar = false

END IF

Wend

LTRIMVBCRLF = Right (STR, LEN (STR) -POS 1)

END FUNCTION

'Continuous carriage return and spaces at the end of the string

Function Rtrimvbcrlf (STR)

Dim Pos, Isblankchar

POS = LEN (STR)

Isblankchar = TRUE

While Isblankchaar and Pos> = 2

IF MID (STR, POS, 1) = "" "" "

POS = POS-1

Elseif MID (STR, POS-1, 2) = vbcrlf THEN

POS = POS-2

Else

Isblankchar = false

END IF

Wend

RTRIMVBCRLF = RTRIM (Left (STR, POS))

END FUNCTION

'Judging whether Email is valid, return 1 indicates correct

Function Isemail (AEMAIL)

DIM ILOCAT, V, ILENGTH, I, Checkletter

IF INSTR (AEMAIL, "@") = 0 or Instr (AEMAIL, ") = 0 THEN

ISEMAIL = 0

EXIT FUNCTION

END IF

Ilocat = INSTR (AEMAIL, "@")

ILocat, Aemail, ".") = 0 or INSTR (Ilocat 1, Aemail, "@")> 0 THEN

ISEMAIL = 0

EXIT FUNCTION

END IF

IF Left (AEMAIL, 1) = "" or right (aemail, 1) = "@" or right (aemail, 1) = "@" TeniseMail = 0

EXIT FUNCTION

END IF

v = "1234567890abdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz _-. @"

ilength = len (aemail)

For i = 1 to ionth

Checkletter = MID (AEMAIL, I, 1)

IF INSTR (V, Checkletter) = 0 THEN

ISEMAIL = 0

EXIT FUNCTION

END IF

NEXT

ISEMAIL = 1

END FUNCTION

'Test: Display server information

Sub showserver

DIM Name

Response.write "

"

For Each Name in Request.ServerVariables

Response.write "

"

Response.write "

" & Name & ""

Response.write "

" & Request.ServerVariables (name) & "
"

Response.write ""

NEXT

Response.write ""

End Sub

'Test: Display RS Results Set and Field Name

SUB Showrs (RS)

DIM STRTABLE, WHATEVER

Response.write "

"

For Each Whate In Rs.fields

Response.write "

" & toHatever.Name & " "

NEXT

STRTABLE = "

" & rs.getstring (, " ", "
," ") &"

Response.write (STRTABLE)

End Sub

'Display text with HTML format

Function TXT2HTML (STR)

IF Isnull (STR) THEN

TXT2HTML = "" "

EXIT FUNCTION

END IF

Str = Replace (STR, CHR (34), "" ")

Str = Replace (STR, "<", "<")

Str = Replace (STR, ">", ">") Str = Replace (STR, CHR (13) CHR (10), "
")

Str = Replace (STR, CHR (9), "")

Str = Replace (STR, "," ")

TXT2HTML = STR

END FUNCTION

'Test: Display debug error message

Sub showerror

DIM Serrmsg

Serrmsg = Err.Source & "& Err.Description

Response.write "

" & serrmsg & ""

Err.clear

End Sub

'Show text counter

Sub showcounter

DIM FS, OUTFILE, FILENAME, COUNT

FILENAME = Server.mappath ("Count.txt")

Set fs = creteObject ("scripting.filesystemobject")

IF fs.fileexists (filename) THEN

Set outfile = fs.opentextfile (filename, 1)

Count = Outfile.readline

Count = count 1

Response.write "

View people:" & count & "
"

Outfile.close

Set outfile = fs.createtextfile (filename)

Outfile.writeline (count)

Else

Set outfile = fs.opentextfile (FileName, 8, True)

COUNT = 0

Outfile.writeline (count)

END IF

Outfile.close

SET FS = Nothing

End Sub

%>

Array ()

Function: Return to an array

Syntax: array (list)

Arguments: characters, numbers

EXAMPLE: <%

DIM myArray ()

For i = 1 to 7

Redim Preserve MyArray (i)

MyArray (i) = weekdayName (i)

NEXT

%>

Result: established a array of 7 elements MyArray

MyArray ("Sunday", "Monday", ... "SATURDAY")

Cint ()

Function: Transform an expression into a digital type

SYNTAX: CINT (Expression)

Arguments: Any valid characters can

EXAMPLE: <%

f = "234"

Response.write cint (f) 2

%>

RESULT: 236

The conversion character "234" is a number "234", and if the string is empty, return 0 value

CreateObject ()

Function: Establish and return an instance of a registered ActiveX component.

Syntax: CreateObject (ObjName)

Arguments: ObjName is a name for any valid, registered ActiveX component.

Example: <% set con = Server.createObject ("AdoDb.Connection")

%>

RESULT:

CSTR ()

Function: Transform an expression as a string.

SYNTAX: CSTR (Expression)

Arguments: Expression is any effective expression.

EXAMPLE: <%

S = 3 2

Response.write "The Resull IS: & CSTR (s)

%>

Result: Transforming Number "5" is character "5".

Date ()

Function: Returns the current system date.

SYNTAX: DATE ()

Arguments: none.

EXAMPLE: <% = DATE%>

Result: 8/4/99

Dateadd ()

Function: Returns a changed date.

SYNTAX: DATEADD (TIMEINTERVAL, NUMBER, DATE)

Arguments: TimeInterval Is The Time Interval To Add; Number IS Amount of

Time Interval to Add; And Date Is The Starting Date.

EXAMPLE: <%

Currentdate = # 8/4/99 #

NewDate = dateadd ("m", 3, currentdate)

Response.write newdate

%>

<%

Currentdate = # 12: 34: 45 PM #

NewDate = dateadd ("h", 3, currentdate)

Response.write newdate

%>

Result: 11/4/99

3:34:45 PM

"m" = "month";

"d" = "day";

IF currentdate is in time format the,

"h" = "hour";

"s" = "second";

Datediff ()

Function: Returns the difference between the two dates.

Syntax: datediff (timeinterval, date1, date2 [, firstdayofweek] [,

Firstweekofyear]])

Arguments: TimeInterval indicates the type of the separation time, such as "M" means "month".

EXAMPLE: <%

FromDate = # 8/4/99 #

TODATE = # 1/1/2000 #

Response.write "There Are" & _

Datediff ("D", FromDate, Todate & _

Days to Millenium from 8/4/99. "

%>

Result: There are still 150 days from 8/4/99 to 2000.

Day ()

Function: Returns a month of the day.

SYNTAX: day (date)

Arguments: Date is any valid date.

EXAMPLE: <% = day (# 8/4/99 #)%>

RESULT: 4

Formatcurrency ()

Function: Return expression, this expression is formatted as a currency value

Syntax: Formatcurrency (Expression [, Digit] [, LeadingDigit] [, PAREN] [, GroupDigit]]]])

Arguments: Digit indicates the value of the number of digits on the right side of the decimal point. The default is -1, indicating that it is

The area setting of the computer; the LeadingDigit tri-state constant indicates whether the small number of decimal points are displayed.

zero.

EXAMPLE: <% = formatcurrency (34.3456)%>

RESULT: $ 34.35

Formatdatetime ()

Function: Returns the expression, this expression is formatted as a date or time

Syntax: formatdatetime (date, [, namedformat])

Arguments: NamedFormat Indicates the value of the date / time format used, if omitted, then use

Vbgeneraldate.

EXAMPLE: <% = formatdatetime ("08/4/99", vblongdate)%>

Result: Wednesday, August 04, 1999

FormatNumber ()

Function: Returns the expression, this expression has been formatted as a value.

Syntax: FormatNumber (Expression [, Digit] [, LeadingDigit] [, PAREN] [,

GroupDigit]]]])

Arguments: Digit indicates the value of the number of digits on the right side of the decimal point. The default is -1, indicating that it is

The area setting of the computer. LeadingDigit i indicates the value of the display bits on the right side of the decimal point. Default value -

1. Instruct it to use the area setting of the computer. PAREN indicates the value of the number of digits on the right side of the decimal point. default

The value is -1, indicating the area setting of the computer. GroupDigit i Indicates the number of display bits on the right side of the decimal point

Numerical value. The default is -1, indicating the area setting of the computer. .

Example: <% = FormatNumber (45.324567, 3)%>

RESULT: 45.325

Formatpercent ()

Function: Return to the expression, this expression has been formatted as a percentage of a percentage of the percentage (multiplication

100). (%)

SYNTAX: FORMATPERCENT (Expression [, DIGIT] [, LeadingDigit] [, PAREN] [,

GroupDigit]]]])

Arguments: Ib.

EXAMPLE: <% = formatpercent (0.45267, 3)%>

RESULT: 45.267%

Hour ()

Function: Returns hours number at 24.

SYNTAX: HOUR (TIME)

Arguments:

EXAMPLE: <% = Hour (# 4: 45: 34 pm #)%>

RESULT: 16

(HOUR HAS BEEN CONVERTED to 24-HOUR SYSTEM)

INSTR ()

Function: Returns the first appearance of the character or string in another string.

Syntax: inStr ([Start,] strSearched, StrsearchFor [, Compare])

Arguments: start for the starting value of the search, STRTOBESEARCHED accepts the search string

StrsearchFor To search for characters. Comparity comparison method (see ASP constant)

EXAMPLE: <%

strText = "this is a test !!"

POS = INSTR (Strtext, "A") Response.write POS

%>

RESULT: 9

INSTRREV ()

Function: Same as above, just from the last search of the string

SYNTAX: Instrrev ([Start,] strsfor [, compare])

Arguments: Ib.

EXAMPLE: <%

strText = "this is a test !!"

POS = INSTRREV (Strtext, "S")

Response.write POS

%>

RESULT: 13

Int ()

Function: Returns the numerical type, not rounded, note that the value is not more than its integer.

SYNTAX: INT (NUMBER)

Arguments:

EXAMPLE: <% = int (32.89)%> <% = int (-3.33)%>

Result: 32 -4

Isarray ()

Function: Judging whether an object is an array and returns a Boolean value.

Syntax: Isarray (Name)

Arguments:

EXAMPLE: <%

strTest = "Test!"

Response.write isarray (StRTEST)

%>

Result: False

Isdate ()

Function: Judging whether an object is a date, return to Boolean

Syntax: Isdate (Expression)

Arguments: Expression is any valid expression.

EXAMPLE: <%

strTest = "8/4/99"

Response.write isdate (StRTEST)

%>

Result: True

ISempty ()

Function: Judging whether an object is initialized, return to the Boolean value.

SYNTAX: ISEMPTY (EXPRESSION)

Arguments:

EXAMPLE: <%

DIM I

Response.Write ISempty (i)

%>

Result: True

Isnull ()

Function: Judging whether an object is empty, return to the Boolean value.

Syntax: isnull (Expression)

Arguments:

EXAMPLE: <%

DIM I

Response.write isnull (i)

%>

Result: False

Isnumeric ()

Function: Judging whether an object is a number and returns a Boolean value.

SYNTAX: IsNumeric (Expression)

Arguments:

EXAMPLE: <%

i = "345"

Response.write isnumeric (i)

%>

Result: True

Even if the number adds quotation marks, ASP still thinks it is a number.

IsObject ()

Function: Judging whether an object is an object, return to the Boolean value.

Syntax: IsObject (Expression)

Arguments:

EXAMPLE: <%

Set con = Server.createObject ("AdoDb.Connection")

Response.Write IsObject (con)

%>

Result: True

Lbound ()

Function: Returns the minimum available subscript of the specified array dimension.

Syntax: lbound (arrayname [, dimension])

Arguments:; Dimension indicates which dimension to return. Use 1 to represent the first dimension, 2 represents the second dimension, and so on. If the Dimension parameter is omitted, the default value is 1.

EXAMPLE: <%

i = array ("Monday", "Tuesday", "Wednesday")

Response.write lbound (i)

%>

Result: 0

Lcase ()

Function: Returns the lowercase form of the string

Syntax: Lcase (String)

Arguments: string is any valid string expression.

EXAMPLE: <%

strTrtest = "this is a test!"

Response.write Lcase (StRTEST)

%>

Result: this is a test!

Left ()

Function: Returns the previous character (including Changth characters) previously character (including Changth characters) on the left side of the string.

Syntax: Left (String, Length)

Arguments:

EXAMPLE: <%

strTrtest = "this is a test!"

Response.write Left (strTest, 3)

%>

Result: thi

Len ()

Function: Returns the length of the string.

Syntax: Len (String | Varname)

Arguments:

EXAMPLE: <%

strTrtest = "this is a test!"

Response.write len (strTest)

%>

RESULT: 15

Ltrim ()

Function: Remove the space left on the left side of the string.

Syntax: Ltrim (String)

Arguments:

EXAMPLE: <%

strTrtest = "this is a test!"

Response.write Ltrim (StRTEST)

%>

Result: this is a test!

MID ()

Function: Returns a string of specific lengths (starting from START, length length).

Syntax: MID (String, Start [, Length])

Arguments:

EXAMPLE: <%

Strtest = "this is a test! Today is monday."

Response.write Mid (Strtest, 17, 5)

%>

Result: Today

Minute ()

Function: Return time division.

Syntax: Minute (TIME)

Arguments:

EXAMPLE: <% = minute (# 12: 45: 32 pm #)%>

Result: 45

Month ()

Function: Return date.

Syntax: Month (Date)

Arguments: Date is any valid date expression.

EXAMPLE: <% = month (# 08/04/99 #)%>

RESULT: 8

Monthname ()

Function: Returns a string Identifying the specified month.

SYNTAX: MONTHNAME (Month, [, ABB])

Arguments: Month Is The Numeric Representation for a Given Month; ABB

(optional) IS a boolean value used to display month abbreviation. Truewill Display The Abbreviated Month Name and false (Default) WILL NOT SHOW

The abbreviation.

EXAMPLE: <% = MONTHNAME (Month (# 08/04/99 #))%>

Result: August

Now ()

Function: Returns The Current System Date and Time.

SYNTAX: now ()

Arguments: None

EXAMPLE: <% = no%>

Result: 8/4/99 9:30:16 AM

Replace ()

Function: Returns a string in Which a specified sub-string Has been

Replaced with another substring a specified number of time.

SYNTAX: Replace (Strtobesearched, Strsearchfor, Strreplacewith "[, Start

] [, COUNT] [, Compare]]])

Arguments: string expression containing a sub-

String to be replaced; strsserchfor is the string express to search for

Withnin strabsearched; strreplacewith is the string expression to replace

Sub-string strsearchfor; start (optional) is the numeric character

Position to begin search; count (optional) IS a value indicating the

CoMPARISION CONSTANT.

EXAMPLE: <%

strTRTEST = "this is an apple!"

Response.Write Replace (Strtest, "Apple", "Orange")

%>

Result: this is an align!

Right ()

Function: Returns the character (including Changth characters) before the string on the right side of the string.

SYNTAX: Right (String, Length)

Arguments:.

EXAMPLE: <%

strTest = "this is an test!"

Response.write Right (strTest, 3)

%>

Result: ST!

RND ()

Function: Generate a random number.

SYNTAX: RND [(Number)]

Arguments:

EXAMPLE: <%

Randomize ()

Response.write rnd ()

%>

Result: Number of any one between 0 and 1

Round ()

Function: Returns the value of the pointing number to the number.

Syntax: Round (Expression [, nuMright])

Arguments: NUMRIGHT number indicates how many counts in the right side of the decimal point. If omitted, then

The Round function returns an integer.

EXAMPLE: <%

I = 32.45678

Response.write Round (i)

%>

Result: 32rtrim ()

Function: Remove the string on the right side of the string.

SYNTAX: RTRIM (String)

Arguments:

EXAMPLE: <%

strTest = "this is a test !!"

Response.write Rtrim (StRTEST)

%>

Result: this is a test !!

SECOND ()

Function: Return second.

SYNTAX: Second (TIME)

Arguments:.

EXAMPLE: <% = second (# 12: 34: 28 pm #)%>

RESULT: 28

Strreverse ()

Function: a string

Syntax: Strreverse (String)

Arguments:

EXAMPLE: <%

strTest = "this is a test !!"

Response.Write Strreverse (StRTEST)

%>

Result: !! Tset A Si SIHT

Time ()

Function: Returns the system time.

Syntax: Time ()

Arguments:.

Example: <% = Time%>

Result: 9:58:28 AM

Trim ()

Function: Remove the space of the string.

Syntax: Trim (String)

Arguments: string is any valid string expression.

EXAMPLE: <%

strTest = "this is a test !!"

Response.write Trim (StRTEST)

%>

Result: this is a test !!

Ubound ()

Function: Returns the maximum subscript of the specified array dimension.

Syntax: ubound (arrayname [, dimension])

Arguments:; Dimension (optional) Specifies which one-dimensional upper boundary integer. 1 means the first

Dimension, 2 indicates the second dimension, and so on. If the Dimension parameter is omitted, the default value is 1.

EXAMPLE: <%

i = array ("Monday", "Tuesday", "Wednesday")

Response.write ubound (i)

%>

RESULT: 2

Ucase ()

Function: Returns the uppercase of the string.

Syntax: ucase (String)

Arguments:

EXAMPLE: <%

strTest = "this is a test !!"

Response.write ucase (StRTEST)

%>

Result: this is a test !!

VARTYPE ()

Function: Returns the value indicating the variable amount type

Syntax: VARTYPE (VarName)

Arguments:

EXAMPLE: <%

i = 3

Response.write Vartype (i)

%>

Result: 2 (Digital) See "ASP constant" for details

Weekday ()

Function: Returns on the first few days of the week.

Syntax: Weekday (Date [, Firstdayofwek])

Arguments:.

EXAMPLE: <%

D = # 8/4/99 #

Response.write weekday (d)

%>

RESULT: 4 (Wednesday)

WeekdayName ()

Function: Returns the name of the first day.

Syntax: weekdayName (Weekday [, ABB] [, Firstdayofweek]) arguments: ABB is optional. Boolean value indicates whether abbreviation represents the name of the day of the week. If the province

Slightly, the default is false, that is, the name of the day does not abrink the name of the day. Firstdayofweek indicates the first day of the week.

Numerical value

EXAMPLE: <%

D = # 8/4/99 #

Response.write weekdayname (Weekday (D))

%>

Result: Wednesday

Year ()

Function: Returns the current year.

Syntax: Year (Date)

Arguments:

EXAMPLE: <% = year (# 8/4/99 #)%>

RESULT: 1999

转载请注明原文地址:https://www.9cbs.com/read-103121.html

New Post(0)
CopyRight © 2020 All Rights Reserved
Processed: 0.041, SQL: 9