ASP syntax quick checklist and ASP common function detailed

xiaoxiao2021-03-06  101

VBScript function function Description Example ABS (value) absolute value. A number of absolute values ​​is its positive value. The absolute value of the empty string (NULL) is also an empty string. The variables that are not initialized are absolutely 0 examples: ABS (-2000) Result: 2000ARRAY (with a tendon separated array element) Array function retracts the value of array elements. Example: a = array (1, 2, 3) B = a (2) Result: 2 Description: Variable B is the value of the second element of the A array. ASC (string) converts the first letters of the string into ANSI (National Standard Symbol). Example: ASC ("Internet") Result: 73 Description: Displays the ANSI word code of the first letter i. CBOOL (Expression) Converts into a Boolean logic value variable (TRUE or FALSE) example: CBOOL (1 2) Result: True CDATE (date expression) replaces a date variable. You can use the isdate function to determine if it can be converted into the date. Example: cdate (now () 2) Result: 2000/5/28 10:30:59 CDBL (expression) Convert to Double variable. CHR (ANSI word) converts the ASCII word code into characters. Example: CHR (72) Result: h cint converted into an integer variable state. Example: CINT ("3.12") Result: 3 CLNG (Expression) Convert to Long Variable Sample. CSNG (expression) is converted into a Single variable. CSTR (Expression) Converts to a string variable. Date () TOP backup system date. Example: Date Result: 2000/5 / 13DATEADD (I, N, D) Plus a date later after a date. I: Set a period of time (DATE) plus a period of time. For example, interval = "d" means that the unit of N is the day. The set value of i is as follows: YYYY Year Year Q Quarter M Month Month D Day Day W Weekday Week HOUR Time N Minute Division S Second Second N: Value Expression, Set a date with a date, can be The positive or negative value, the positive value represents the addition (the result of> DATE), and the negative value is reduced (the result is> Date previous date). D: Date to be subtracted. Example: DATEADD ("M", 1, "31-JAN-98") Result: 28-Feb-98 Description: Add a date 31-Jan-98 plus a month, resulting 28-Feb-98 rather than 31- Fe-98.

Example: DateAdd ("D", 20, "30-JAN-99") Results: 1999/2/9 Description: Add a date 30-JAN-99 to 20 days later. Datediff (i, d1, d2 [, fw [, fy]]) calculates the period between two dates. I: Set the period of calculation between two dates. For example,> i = "m" indicates the calculated unit as the month. > I's set value such as yyyy> Year Year Q Quarter M Month Month D Day Day W Weekday Week HOUR Time M minute division S Second Seconds D1, D2: Two date expressions during calculation, if> Date1 Besides, the results between the two dates are positive; if> DATE2 is earlier, the result is a negative value. FW: Set the week a week for the week, if it is not set as Sunday. > The setting value of the FW is as follows: 0 Use the> API setting value. 1 Sunday 2 Monday 3 Tuesday 4 Wednesday 5 Thursday 6 Friday 7 Saturday FY: Set the first week of one year, if it is not set, it means that the week is the first week of one year. > The set value of FY is as follows: 0 Use the> API setting value. January 1st, the first week of one year, at least four days, the first week of the first week of one year, 3 included the first week of seven days, the first week of one year: datediff ("D "" 25-MAR-99 "," 30-JUN-99 ") Results: 97 Description: Show the period between the two dates to 97 days. DatePart (i, d, fw [, fw]] is transmitted back to some of the date. > I: Set back to that part. For example,> i = "d" indicates that the return part is the day. > I's set value is as follows: YYYY YEAR Year Year Q Quarter M Month Month D Day Day W Weekday Week HOUR Time M Minute Dividers S Second Second D: The date to be calculated. > FW: Set the first day of the week for the week, if it is not set, it is expressed as Sunday. > The setting value of the FW is as follows: 0 Use the> API setting value. 1 Sunday 2 Monday> 3 Tuesday 4 Wednesday 5 Thursday 6 Friday 7 Saturday FY: Set the first week of one year, if it is not set, it means that the week is one year in the first week of one year. > The set value of FY is as follows: 0 Use the> API setting value. January 1st, the first week of one year 2, at least the first week of the first week of the first week, 3 included the first week of seven days, the first week of one year: datepart ("M "," 25-MAR-99 ") Result: 3 Description: Display the monthly part of a date. DateSerial (Year, Month, day) conversion (Year, Month, day) is a date variable. Example: DateSerial (99, 10, 1) Result: 1999/10 / 1DateValue (String or expression of the date) Converts to a date variable state, date from January 1,100 to December 31,9999. Format is MONTH, DAY, AND YEAR or MONTH / DAY / YEAR.

Such as: DecEmber 30, 1999, DEC 30, 1999, 12/30/1999, 12/30/99: DateValue ("January 1,2002") Result: 2002/1 / 1DAY (Date string or expression) The "Japanese" part of the return date. Example: DAY ("12/1/1999") Result: 1FIX (expression) TOP conversion string into an integer digital state. The same as the INT function. Returns NULL if null. INT (NUMBER) and FIX (Number) are negative. Such as int (-5.6) = - 6, FIX (-5.6) = - 5. Example: Fix (5.6) Result: 5HEX (Expression) TOP Retrieve Numerical hexadecimal value. If the expression is NULL, hex (expression) = null, if the expression = EMPTY, HEX (expression) = 0. The 16 carry can be represented by "& H", such as 16 carry & H10 means a decimal 16. Example: HEX (30) Result: 1EUR (Time string or expression) Recycling time "Hours" part. Example: Hour ("12:30:54") Results: 12instr ([Start,] string1, string2 [, compare]) TOP will cause a string from left and another comparison, back the first identical location . START is compared from the first few words. If START omits START, String1 is a string expression to be checked, and string2 is a string expression to be compared, and Compare is a comparison method, compare = 0 Table binary comparison method, Compare = 1 table text comparison method, if the Compare is omitted, it is a preset binary comparison method. Example: INSTR ("ABC123DEF123", "12") Result: 4instrrev ([Start,] string1, string2 [, compare]) Transfer a string from right and left with another comparison, and then back the first identical location. START is compared from the first few words. If START omits START, String1 is a string expression to be checked, and string2 is a string expression to be compared, and Compare is a comparison method, compare = COMPARE = 0 Table binary comparison method, Compare = 1 table text comparison method, if the Compare is omitted, it is a preset binary comparison method. Example: Instrrev ("ABC123DEF123", "12") Result: 10INT (expression) The integer part of a value. The same is the same as the FIX function. Example: INT (5.6) Result: 5isArray (Variable) Test Variable is (true) No (false) is an array. Example: Isarray (3) Result: False Description: Not an array. Isdate (Expression of a date or string) can be converted to a date. Date from January 1,100 A.D. to December 31,9999 A.D. Example: Isdate ("DECEMBER 31, 1999") Result: True Description: You can convert a date.

ISEMPTY test variable is (true) No (false) has been initialized: ISEMPTY (A) Result: TRUEISNULL (Variable) Test variable is (true) No (false) is not valid data. Example: Isnull ("") Result: false Description: It is a valid data. ISNUMERIC is (TRUE) No (false) is a number. Example: ISNUMERIC ("abc123") Result: false Description: Not a number. LCASE (string expressions) TOP conversion strings are lowercase. Convert part of the uppercase letters into lowercase. The rest of the string remains unchanged. Example: LCASE ("abc123") Result: Abc123left (string expression, length) takes a few words on the left side of the string. Length is a word. The LEN function can know the length of the string. Example: Left ("ABC123", 3) Result: Abclen (string expressive variable) obtains the length of the string. Example: LEN ("ABC123") Result: 6Ltrim (string expression) Remove the blank word on the left of the string. RTRIM removes the blank word on the right side of the string, the TRIM function removes the blank word on the left and right sides of the string. Example: LTRIM ("456 " ABC ") Result: 456ABC123MID (string expressions, start [, length]) TOP take a few words in the string. START is taken from the first few words, Length is a few One word, if Length is taken from Start to the far right. The length of the string can be known from the LEN function. Example: MID ("ABC123", 2, 3) Result: C12minute (Date string or expression) The "minute" part of the return time. Example: Minute ("12:30:54") Results: 30Month (String or Expressions) Remove the "Month" part of the date. Example: MONTH ("12/1/2001") Result: 12MonthName (Month [, Abbreviate]) is sent back to the moon. Month: The number of the moon name to be passed to 1 to 12. For example, 1 represents January, 7 represents July. Abbreviate: Yes (false) is abbreviated, such as march, abbreviated as Mar. The default is false. The moon name of Chinese has no zone. Example: MONTHNAME (7) Result: July now () transmission back system date time. Example: NOW () Result: 2001/12/30 10:35:59 Amoct () The eight-entered value of the value. The eight-in position can be represented by "& O", such as an octave & O10 means a decimal 8. Example: OCT (10) Result: 12Replace (string expression, findnreplacewith [, start [, count [, compare]]) replaces a string. Looking for the original string (find), if it is found, it is replaced into a new string (ReplaceWith). Find: Status to look for the replacement of the original string. ReplaceWith: Replace the word. START: From the first few words to find replacement, if it is not set, it is started from the first word. COUNT: The number of substitutions. If it is not set, all the strings that all the strings that are looking for are all replaced.

Compare: Look for comparison methods, compare = 0 represents binary comparison method, compare = 1 table text comparison method, compare = 2 table determines the comparative data type, if the Compare is a preset binary comparison method. Example: Replace ("Abcd123ABC", "AB", "AB") Result: ABCD123ABCRIGHT (string expression, length) takes a few words on the right side of strings, Length is taken a few words. The LEN function can know the length of the string. Example: Right ("ABC123", 3) Result: 123RND [(Number)] 0 ~ 1 Random Random Numeris. Number is any valid numerical expression. If Number is less than 0, the same random random value is obtained each time. Number is greater than 0 or not provided to obtain the next random random value. > Number = 0 Indicates the recently generated random random value. In order to avoid obtaining the same random random number, randomize can be added prior to the RND function. Example: RND Results: 0.498498Round (numerical expression [, d]) rounded. D: For the first time to go to the first decimal decimal, if the omitted is omitted, it is round to the integer. Example: Round (30635, 1) Result: 3.6rtrim (string expression) Remove the blank word on the right side of the string. LTRIM removes the blank word on the left of the string, the Trim function removes the blank word on the left and right sides of the string. Example: RTRIM ("ABC123") "456" Result: ABC123456Second (Time string or expression) TOP back time of "second" part. Example: SECOND ("12:30:54") Result: 54Space (number of repetitions) Gets the same blank string. Example: a " Space (5) " B Results: a b Description: Five blank characters in the middle of A and B. String (Number of repetitions, the word to be repeated) gets the same string. Example: String (5,71) Results: GggggStrreverse (String (10, 71)) reverses a string order. Example: Strreverse ("abc") Result: CBATIME () Remove the time of the system. Example: Time Results: 10:35:59 PmtimeSerial (Hour, Minute, Second) Converts Specifies (Hour, Minute, Second) into a time variable type. Example: TimeSerial (10, 31, 59) Result: 10: 31: 59TimeValue (String or expression of the date) Convert to a time variable. Date string or expression from 0:00:00 (12:00:00 A.m.) to 23:59:59 (11:59:59 p.m.). Example: TimeValue ("11:59:59") Results: 11: 59: 59Trim (string expression) Remove blank characters on the left and right sides of the string. Example: TRIM ("ABC123") Result: Abc123ucase () TOP conversion string is uppercase. Convert the part of the lowercase letter to uppercase, the remaining part of the string constant. Example: UCASE ("ABC123") Result: ABC123VARTYPE (variable) is transmitted back to a variable type.

As the TypenAme function, the VARTYPE is transmitted back to the variable type code, the TypenAME is back into the name of the variable type. Example: VARTYPE ("I Love You!") Result: 8WeekDay (Date Expression, [FW]) is sent back to the number of days. FW: Set the first day of the week is the day of the week. If the table 1 is omitted (Sunday). The firstdayfweek setpoint is: 1 (Sunday), 2 (Monday), 3 (Tuesday), 4 (Wednesday), 5 (Thursday), 6 (Friday), 7 (Saturday). Example: Weekday ("1/1/2000") Result: 7WeekDayName (W, A, FW) passed back to the name of the day. W: Yes (true) No (false) is an abbreviation. Such as march, abbreviated as Mar. Preset is false. Several Japanese Nameless Writing in Chinese. FW: Set the first day of the week is the day of the week. If the table 1 is omitted (Sunday). Set the name to be transferred back to the day of the week, for the first few days in the week. A: 1 (Sunday), 2 (Monday), 3 (Wednesday), 5 (Thursday), 6 (Friday), 7 (Saturday). Example: WeekdayName ("1/1/2000") Result: Saturday Year () Remove the "Year" part of the date. Example: Year ("12/1/2000") Results: 2000 ASP Function Detailed Array () Function: Returns an array syntax: array (list) arguments: character, number can be eXample: <% DIM MyArray () for i = 1 to 7 redim preserve myarray (i) MyArray (i) = weekdayName (i) Next% [/ img] Result: Create 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 character can be eXample: <% f = "234" response.write CINT (f) 2% [/ IMG] 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")% [/ img] Result: cstr () Function : Transforming an expression as a string. Syntax: cstr (expression) arguments: expression is any valid expression. Example: <% s = 3 2 response.write "The result is:" & cstr (s)% [/ img] Result: Transformation Number "5" is the character "5".

Date () Function: Returns the current system date. Syntax: Date () arguments: none. EXAMPLE: <% = DATE% [/ IMG] Result: 8/4 / 99dateAdd () 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% [/ IMG] <% currentdate = # 12: 34: 45 PM # newdate = dateadd ("h", 3, currentdate) response.write newdate% [ / Img] Result: 11/4/99 3:34:45 PM "M" = "MONTH"; "D" = "day"; if currentdate is in time format dam, "h" = "hour"; "s "=" Second "; Datediff () function: Returns the difference between the two dates. Syntax: datediff (TimeInterval, Date1, Date2 [, Firstdayofweek [, Firstweekofyear [/ IMG] [/ IMG]) 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. "% [/ Img] Result: 150 days from 8/4/99 to 2000.day () function: returns a month. Syntax: day (date) arguments: Date is any Effective date. EXAMPLE: <% = day (# 8/4/99 #)% [/ img] Result: 4Formatcurrency () Function: Return expression, this expression is formatted as a currency value syntax: formatcurrency (Expression [, DIGIT [ , LeadingDigit [, PAREN [, GroupDigit [/ IMG] [/ IMG] [/ IMG] [/ IMG]) 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)% [/ IMG] Result: $ 34.35formatdatetime () Function: Return expression, this expression is formatted as a date or time syntax: formatdatetime (date, [, namedformat [/ i] Arguments: NamedFormat Indicates the value of the date / time format used, if omitted, use vbGeneldate. Example: <% = formatdatetime ("08/4/99", vblongdate)% [/ img] Result: Wednesday, August 04 1999FormatNumber () Function: Return expression, this expression has been formatted to values. Syntax: formatNumber (Expression [, Digit [, LeadingDigit [, Paren [, GroupDigit [/ IMG] [/ IMG] [/ IMG] [ / IMG]) 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 is -1, indicating the area setting of the computer. GroupDigit i 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. EXAMPLE: <% = formatNumber (45.324567, 3)% [/ img] Result: 45.325Formatpercent () function: Return expression, this expression has been formatted as a percentage of a percentage of a percentage (multiplying 100).

(%) SYNTAX: FORMATPERCENT (Expression [, DIGIT [, LeadingDigit [, Paren [, GroupDigit [/ IMG] [/ IMG] [/ IMG] [/ IMG]) arguments: The same. EXAMPLE: <% = formatpercent (0.45267, 3)% [/ img] Result: 45.267% HOUR () Function: Returns hours number at 24. Syntax: Hour (Time) arguments: example: <% = Hour (# 4: 45: 34 pm #)% [/ IMG] Result: 16 (HOUR HASTEM) INSTR () Function: Returns the first appearance of the first appearance in another string. Syntax: Instr ([START, [/ IMG] STRTOBESEARCHED, STRSEARCHFOR [, Compare [/ IMG]) arguments: start for the starting value of the search, STRTOBESEARCHED accepts searches String strSearchFor to search for character Compare comparison mode (detailed view ASP constant) EXAMPLE: <% strText = "this IS A Test !! "POS = INSTR (STRText," A ") Response.write POS% [/ IMG] Result: 9instrrev () Function: The same, just from the last search of Syntax: Instrrev ([START, [ / Img] strSearchfor [, compare [/ img]) arguments: 同. EXAMPLE: <% strText = "this is a test !!" POS = ISTRREV (Strtext, "S") Response.Write POS% [/ IMG ] Result: 13int () Function: Returns the numeric type, not surrounded.

Syntax: int (Number) arguments: example: <% = int (32.89)% [/ img] Result: 32isArray () function: Determine whether an object is an array, returns the Boolean value. Syntax: isarray (name) arguments: example: <% StrTest = "Test!" Response.write isarray (strTest)% [/ img] result: falseisdate () function: Determine 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)% [/ img] result: trueiseMpty () function: Determine whether an object is initialized, return to Boolean. Syntax: ISempty (Expression) arguments : Example: <% DIM I Response.write ISempty (i)% [/ IMG] Result: Trueisnull () Function: Determines whether an object is empty, return to Boolean value. Syntax: isnull (Expression) arguments: example: <% DIM I Response.write isnull (i)% [/ img] result: false isnumeric () function: Determine if an object is a number, return Boolean value. Syntax: ISNUMERIC (Expression) arguments: example: <% i = "345" Response .write isnumeric (i)% [/ img] Result: True Even if the number adds quotation marks, ASP still thinks it is a number. IsObject () function: Determine 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)% [ / IMG] Result: TruelBound () Function: Returns the minimum available subscript of the specified array dimension. Syntax: lbound (arrayname [/ img]) arguments: Dimension indicates which one of the minimal boundaries to returns. 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)% [/ img] Result: 0lcase () Function: Return String's lowercase form syntax: lcase (string) arguments: string is any valid string expression. EXAMPLE: <% string = "this is a test!" Response.write lcase (strTrtest)% [/ img] Result: this is a TEST! LEFT () Function: Returns the previous character (including Changth characters) on the left side of the string (including ZENGTH characters). Syntax: Left (string, length) arguments: example: <% strTrtest = "this is a test!" Response .write left (strTest, 3)% [/ img] Result: thilen () function: Returns the length of the string. Syntax: len (string | varname) arguments: example: <% strTrtest = "this is a test!" Response .write len (strTest)% [/ img] Result: 15Ltrim () 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)% [/ img] Result: this is a test! mid () function: Returns a specific length string (starting from START, length length). Syntax: MID (String, Start [, Length [/ IMG] ) Arguments: example: <% strTest = "this i Sa Test! Today is Monday. "Response.write MID (StRTEST, 17, 5)% [/ IMG] Result: Todayminute () Function: Return time division. SYNTAX: Minute (time) arguments: example: <% = Minute (# 12: 45: 32 pm #)% [/ img] Result: 45MONTH () Function: Return date. Syntax: Month (Date) arguments: Date is any valid Date Expression. EXAMPLE: <% = Month (# 08 / 04/99 #)% [/ img] Result: 8MONTHNAME () Function: returns a string Identifying the specified month. Syntax: monthname (Month, ABB [/ IMG]) arguments: month is the name 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 #)) % [/ Img] result: AugustNow () Function: returns the current system date and time. Syntax: now () arguments: none example: <% = no% [/ img] Result: 8/4/99 9:30: 16 AMReplace () 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 [/ IMG] [/ IMG] [/ IMG]) 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 Indicating The Comparision Constant. EXAMPLE: <% strTest = "this is an apple!" Response.Write Replace (StRTEST, "Apple", "Orange")% [/ IMG] Result: this is an orange! Right () function: Return string right side Length character (including ZENGTH characters). Syntax: Right (string, length) arguments:. example: <% strTrtest = "this is an test!" Response.write Right (strTrtest, 3)% [/ IMG] Result: st! Rnd () Function: Generate a random number. Syntax: RND [(Number) [/ IMG] arguments: example: <% randomize () response.write rnd ()% [/ img] Result: any A number of round () function between 0 and 1: Returns the number of rounded values ​​in the pointing number. Syntax: Round (Expression [, Numright [/ IMG]) 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)% [/ img] 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)% [/ img] Result: this is a test !! second () function: return second. Syntax: Second (TIME) Arguments:. Example: <% = Second (# 12: 34: 28 pm #)% [/ img] result: 28strreverse () function: reverse row string Syntax: strreverse (string) arguments: example: <% strTrtest = "This is a test !!" response.write strreverse (strTest)% [/ img] Result: !! Tset A SI SIHTTIME () Function: Return to the system time. Syntax: Time () arguments:. Example: <% = TIME % [/ Img] result: 9:58:28 Amtrim () Function: Remove the space of the string. Syntax: Trim (string) arguments: string is any valid string expression. EXAMPLE: <% strTrtest = "this is A TEST !! "Response.write Trim (strTest)% [/ img] Result: this is a test !! ubound () function: Returns the maximum available subscript of the specified array dimension. Syntax: Ubound (arrayname [, Dimension [/ IMG ]) Arguments: Dimension (Optional) Specify Back Which dimension of the upper world. 1 Represents the first dimension, 2 means a second dimension, and so on.

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

New Post(0)