asp commonly used functions Author: Unknown Article Source: Unknown Nature article: Reprinted Views: 6 Release date: 2004-10-26 Array () FUNCTION: returns an array SYNTAX: Array (list) ARGUMENTS: characters, numbers may EXAMPLE: <% DIM myarray () for i = 1 to 7 redim preserve myarray (i) MyArray (i) = weekdayName (i) Next%> Result: established an array with 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 Transformation 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: .35 formatdatetime () Function: Return expression, this expression is formatted as date or time syntax: formatdatetime (date, [, namedformat]) arguments: namedFormat instruction The value of the date / time format used, if omitted, use vbGeneraldate. Example: <% = formatdatetime ("08/4/99", vblongdate)%> Result: Wednesday, August 04, 1999 FormatNumber () Function: Return Expression, this expression has been formatted into values. 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).
(%) SYNTAX: FORMATPERCENT (Expression [, Digit] [, LeadingDigit]]]]]) arguments: 同. EXAMPLE: <% = formatpercent (0.45267, 3)%> Result: 45.267% HOUR () Function: Returns the number of hours in 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 place in another string in another string. SYNTAX: INSTR ([START,] STRTOBESEARCHED, STRSEARCHFOR [, Compare]) arguments: start is the starting value of the search, STRTOBESEARCHED Accepts String Strings StrsearchFor To search for characters. Compare comparison mode (detailed view ASP constant) Example: <% strText = "this is a test !!" POS = INSTR (Strtext, "A") Response.write POS% > Result: 9 INSTRREV () Function: The same, just from the last search of Syntax: INSTRREV ([Start,] strtobesearched, strsforchfor [, compare]) arguments: 同. EXAMPLE: <% strText = "this is a Test !! "POS = INSTRRREV (Strtext," S ") Response.write POS%> Result: 13 int () function: Return numeric type, not surrounded, 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: Determines whether an object is an array and returns a Boolean value. Syntax: Isarray (Name) arguments: example: <% strTrtest = "test!" Response.write isarray ()%> Result: false isdate () function: Date to determine if an object is a date, return to Boolean Syntax: Isdate (Expression) ) Arguments: expression is any value: <% strast = "8/4/9" response.write isdate (strtest)%> Result: True ISEMPTY () Function: Determines whether an object is initialized, return to Boolean. Syntax : ISempty (Expression) arguments: example: <% DIM I response.write iempty (i)%> Result: True isnull () Function: Determines whether an object is empty, return to the Boolean value. Syntax: isnull (Expression) arguments: example: Example : <% DIM I Response.write isnull (i)%> Result: false isnumeric () function: Determine whether an object is a number, return to the Boolean value. Syntax: isnumeric (expression) arguments: example: <% i = "345" Response.write isnumeric (i)%> RESUE Even if the number adds quotation marks, ASP still thinks it is a number. IsObject () function: Determines if an object is an object, returns a Boolean value. Syntax: isobject (expression) arguments: example: <% set con = Server.createObject ("AdoDb.Connection) Response.write isobject (con)%> Result: True Lbound () Function: Returns the minimum subscript of the specified array dimension. Syntax: lbound (arrayname [, dimension]) arguments:; Dimension indicates which one 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 is 1. EXAMPLE: <% i = array ("Monday", "Tuesday", "Wednesday") Response.write LBound (i)%> Result: 0 Lcase () Function: Return Strings Small write form syntax: lcase (string) arguments: string is any valid string expression. EXAMPLE: <% strate = "this is a test!" Response.write lcase (strTrtest)%> Result: this is a test! Left () Function: Returns the previous character (containing ZENGTH characters) on the left side of the string (including ZENGTH characters). Syntax: Left (string, length) arguments: example: <% strTest = "this is a test!" Response.write LEFT , 3)%> Result: thi g () 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 string. Syntax: Ltrim (String) arguments: example: <% strTrtest = "this is a test!" Response.write ltrim (strtst)%> Result: this is A Test! MID () Function: Returns a specific length string (starting from START, length length). Syntax: MID (String, Start [, Length]) arguments: example: <% strate = "this is a test! Today is monday. "Response.write MID (StRTEST, 17, 5)%> Result: Today Minute () Function: Returns 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 substring has been replaced with another substring a specified number of times SYNTAX:. Replace (strToBeSearched, strSearchFor, strReplaceWith [, start] [, count] [, compare]]]) ARGUMENTS: strToBeSearched is a string expression containing a sub- string to be replaced; strSearchFor is the string expression to search for within strToBeSearched; 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 indeicating the comparision constant. EXAMPLE: <% strt EST = "this is an apple!" Response.write Replace (Strtest, "Apple", "Orange")%> Result: this is an orange! Right () Function: Returns the first character of the first side character in the right side of the string ( Contained paradax characters). Syntax: Right (string, length) arguments:. EXample: <% strTrtest = "this is an test!" Response.write right (strTrtest, 3)%> Result: st! Rnd () Function : Generate a random number. Syntax: RND [(Number)] arguments: example: <% randomize () response.write rnd ()%> Result: Number of Round () Function between 0 and 1: Return Press The number of positions is a value of rounding. Syntax: Round (Expression [, Numright]) arguments: Numright number indicates how many counts in the right side of the decimal point.
If omitted, the Round function returns an integer. EXAMPLE: <% i = 32.45678 response.write runk (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 (strTRTEST)%> Result: this is a test !! second () function: Return second. Syntax: second (time) arguments:. eXample: < % = SECOND (# 12: 34: 28 PM #)%> Result: 28 strreverse () Function: Reverse row string Syntax: strreverse (string) arguments: example: <% strTrtest = "this is a test !!" Result: !! tset a si siht time () function: Return system time. Syntax: Time () arguments:. example: <% = time%> Result: 9:58:28 AM Trim () function: Remove the space left and right. Syntax: Trim (String) arguments: string is any valid string expression. EXAMPLE: <% strTrtest = "this is a test !!" Response.write Trtem (strtest)%> Result: this is a test !! Ubound () Function: Returns the maximum available subscript of the specified array dimension. Syntax: ubound (arrayname [, dimension]) arguments:; Dimension (optional) Specifies which one-dimensional upper boundary . 1 Represents the first dimension, 2 means a 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: Return characters String form. Syntax: ucase (string) arguments: example: <% strTrtest = "this is a test !!" response.write ucase (strTrtest)%> Result: this is a test !! varType () Function: Return Indicates the value of the variable quantum type syntax: VARTYPE (VARNAME) arguments: example: <% i = 3 response.write Vartype (i)%> Result: 2 (Digital) See "ASP constant" weekday () Function: Return to a week The first few days. 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 few days. Syntax: WeekdayName (Weekday [, ABB] [, Firstdayofweek]) arguments: ABB is optional. Boolean value indicates whether abbreviation represents the name of the day of the week. If omitted, the default value is false, that is, the name of the day does not abrink the name of the day. Firstdayofweek indicates the value of the week on the first day of the week EXAMPLE: <% d = # 8/4/99 # response.write weekdayname Result: Wednesday Year () Function: Returns the current year. Syntax: Year (Date) arguments: example: <% = year (# 8/4/99 #)%> Result: 1999 [Print this article] [Close this Window] Powered by: SuperPig Webmaster QQ: 9988440.Processed in 0.027007 Second (s)