ASP common functions (1)

zhaozj2021-02-16  75

Array () Function: Returns an array syntax: array (list) arguments: characters, numbers can be elimple: <% DIM myarray () for i = 1 to 7 redim preserve myarray (i) MyArray (i) = weekdayname (i) Next%> Result: Create an array of 7 elements MYARRAY ("Sunday", "Monday", ... "Saturday") CINT () Function: Transform an expression into a digital type Syntax: CINT (Expression) arguments: Any valid character can be eXample: <% f = "234" response.write cint (f) 2%> Result: 236 conversion character "234" is a number "234", if the string is Empty, return 0 value creteObject () function: Establish and return an instance of a registered ActiveX component. Syntax: creteObject (objName) arguments: ObjName is the name of any valid, registered ActiveX component. EXAMPLE: <% set con = Server.createObject ("adodb.connection")%> Result: cstr () Function: Transformation The expression is a string. SYNTAX: CSTR (Expression) arguments: expression is any valid expression. Example: <% s = 3 2 response.write "the result is:" & cstr (s)%> Result: Transformation Number "5" is the 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 intervals 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 [, firstwekofwek]]) arguments: timeInterval indicates the type of time separation, such as "M" means "month". EXAMPLE: <% fromDate = # 8/4/99 # Todate = # 1/1/2000 # response.write "There" & _ 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 value is -1, indicating the area setting of the computer; the LeadingDigit tri-state constant indicates whether the zero in front of the small numerical point is displayed.

Example: <% = formatcurrency (34.3456)%> Result: $ 34.35 formatdatetime () function: Return expression, this expression is formatted as a date or time syntax: formatdatetime (date, [, namedformat]) arguments: namedFormat indicator Values ​​used for date / time format, if omitted, use vbGeneralDate. Example: <% = formatdatetime ("08/4/99", vblongdate)%> Result: Wednesday, August 04, 1999 FormatNumber () Function: Return Expression The 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 the area setting of the computer. LeadingDigit i indicates the value of the display bits on the right side of the decimal point. The default is - 1, indicating the area setting of the computer. PAREN indicates the value of the number of digits on the right side of the decimal point. The default value is -1, indicating that the area settings of the computer are used. GroupDigit i indicates the value of the display bit on the right side of the decimal point. The default is -1, indicating the area setting of the computer. (45.324567, 3)%> Result: 45.325 formatpercent () function: Return expression, this expression has been formatted as a percentage of a percentage of the tail (multiplying 100).

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

New Post(0)