ASP common functions (1)

xiaoxiao2021-03-06  110

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

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

New Post(0)