ASP common functions

zhaozj2021-02-16  102

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, so that this is pushed. 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. True

Will 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: 32

RTRIM ()

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-11816.html

New Post(0)