/* ------------------- ASP document reference set -----------------------*/
* --> Author: Crawler
* --> Time: 2007-4.28---2007-4.30)
* --> Contact: caolvchong@gmail.com
* --> Document function:
1. I reviewed ASP and deepened my understanding of ASP structure and ASP experience.
2. It can be used for ASP reference and self-written for reference.
This is Part 5: Common VBScript functions in ASP
/* ----------------------- Common functions of VBScript in ASP ---------------------*/
* --> Judgment functions:
Isarray (): determines whether it is an array.
Isdate (): determines whether it is time-type data. Time-type data can be as follows:
"October 19,196 2" or #2006/11/3 # Or #2006-11-3 #
Isempty (): determines whether a variable has been initialized, that is, whether the value is empty
Isnull (): determines whether the variable has nothing
Isnumeric (): determines whether it is a number.
Isobject (): determines whether it is an object.
Return Value: boolean (true or false)
* --> Common conversion functions:
Abs (): Absolute Value Function
Asc (): returns the ANSI character code corresponding to the first letter of the string.
The Ascb function is used together with a string containing byte data. Ascb is not the character generation that returns the first character
Returns the first byte. Ascw is provided for 32-bit platforms that use Unicode characters. It returns
Unicode (WIDE) character code, so you can avoid Code Conversion from ANSI to Unicode.
Chr (): returns the character corresponding to the specified ANSI character code.
The Chrb function is used together with the byte data contained in the string. Chrb does not return one or two bytes.
But always returns a single byte. Chrw is a 32-bit platform that uses Unicode characters.
Provided. Its parameter is a Unicode (wide character) character code, so it can avoid converting ANSI
To Unicode characters.
Int (), Cint (), Fix () and Clng (): returns an integer.
Difference: int () can accept long integer data, and always remove the data after the decimal point
Cint () can only accept short integer data, and use rounding to process decimal places
Clng () can accept long integer data, and also uses rounding to process Decimals
If a positive number is used, the fix () and int () are the same. The difference between them is a negative number:
The Int function returns the first negative integer less than or equal to number.
The Fix function returns the first negative integer greater than or equal to the number parameter.
Cstr (): returns a string.
* --> Common time functions:
Date: returns the current system Date. The output format is 2007-3-25.
Time: returns the current system Time. The output format is as follows: 14: 31: 32.
Year: The Year of the returned time.
Day: returns the Day (the number between 1 and 31) of the date)
Month: returns the Month of the date (that is, the number between 1 and 12)
Weekday: returns the day of the week (number between 1 and 7)
Format: weekday (date [, the day of the week is the first day]). By default, Sunday is the first day.
Weekday (date, 2) indicates that Monday is the first day, and 7 indicates that Saturday is the first day.
Hour: the Hour of the returned time (0 to 23)
Minute: the Minute of the returned time (0 to 59)
Second: the number of seconds (0 to 59) of the returned time)
Now: returns the current system time. The output format is 14:32:49.
Monthname (parameter 1 [, parameter 2]): returns the name of the month of the corresponding date. 1 returns January ..
Number or expression between 1 and 12
Optional parameter 2: true or false. The abbreviated month is returned in English.
Weekdayname: returns the day of the week"
Format: Weekdayname (the day after the first day, whether it is short for output, specified on the first day)
By default, the first day is Sunday, that is, 1, 2, and Monday is the first day.
The day after the first day means: for example, if the first day is set to 2, Monday is set to the first day,
Then enter 2 in the day of the first day, which indicates Tuesday, and so on.
Abbreviation: true or false; abbreviation of return week in English
The following are functions about time settings:
DateAdd (type, interval, base Time): returns the date with the specified time interval added.
Type (enclosed in quotation marks ):
Yyyy: Year; q: quarter; m: month; y: day of the year; d: Day; w: day of the week; ww: Week; h: hour;
N: minute; s: Second
Interval: it is a number that specifies the interval of values.
Base time: A Date function.
Example:
NewDate = DateAdd ("m", 1, "31-Jan-95 ")
Response. Write (newdate)
Output
DateDiff (type, date 1, date 2 [, which day is the first day of the week [, and which day is the first star of the year
Period]): returns the interval between two dates.
Type: The DateAdd Type above.
Date 1, date 2: Two Date and Time
Specify the first day of a week. The default value is Sunday.
Specify the first week of the year. The default value is the week of April 1.
DatePart (type, date [, which day is the first day of the week [, which day is the first day of the year]):
Returns the specified part of a given date.
Type: The DateAdd Type above.
Date: the number of days or expression
Specify the first day of a week. The default value is Sunday.
Specify the first week of the year. The default value is the week of April 1.
Example: Use the newdate
Reponse. write ("yyyy", newdate), 1995 will be returned
DateSerial (year, month, day): returns the date format data of the specified year, month, and day.
For example:
DateSerial (1970,1, 1) returns 1970-1-1
In addition, the validity period of the year is 100-9999.
DateValue (date string): returns the corresponding date format data
TimeSerial (hour, minute, second): returns the date format data of the specified hour, minute, second
For example:
TimeSerial (, 6) returns
TimeValue (Time string): returns the corresponding time format data
* --> Common mathematical functions:
Trigonometric function:
Cos (): returns the cosine.
Sin (): returns the sine value.
Tan (): returns the tangent.
Atn (): returns the arc tangent value.
Random function:
Randomize: Random Seed Value
Rnd: returns a random value smaller than 1 but greater than or equal to 0.
Logarithm function:
Log (): returns the natural logarithm of a value. The constant e is about 2.718282.
Exp (): returns the power of e (the base of the natural logarithm), log inverse operation.
Functions:
Sqr (): returns the square root of a value.
Rounding function:
Abs: Absolute Value Function
Int, Fix, and Cint can be rounded up.
Round (): Rounding Function
Format: round (number or its expression [, digit])
Description of the number of digits: The number indicates the number of digits to the right of the decimal point. If omitted
The Round function returns an integer.
Example:
Num = 3.14159
Response. write round (num, 2) 'returns 3.14
Symbol functions:
Sgn (): Judge the Digit Symbol
0: Return 0
Positive number: return 1
Negative:-1
String processing functions:
The most common string processing functions:
Len (): returns the string length (lenb: returns the number of characters in the string)
Left (string, length): returns the number of characters counted from the Left of the string (leftb)
Mid (string, start position [, length]): returns a specified number of characters from the string
If the start position exceeds the string length, return the control string
If the length is not specified or exceeds the last character of the string
Characters (midb)
Right (string, length): returns the specified number of characters (rightb) from the Right of the string)
Note: leftb, midb, and rightb indicate to use. length together with the byte data contained in the string.
Not specify the number of returned strings, but the number of bytes)
Replace (string expression, the searched substring, used to Replace the substring [, compare [, number
[, Starting position])
Optional parameters:
Comparison: The default value is 0, indicating binary comparison.
Number: the number of substrings to replace. If omitted, the default value is-1, indicating all
Possible replacement. Must be used when associating with the start position
Start position: Number of substrings to be replaced. If omitted, the default value is-1, indicating
Make all possible replacements. Must be used when associating with the "quantity"
Trim (string): removes spaces on both sides of the string.
Rtrim (string): removes spaces on the right.
Ltrim (string): removes spaces on the left.
Split (string expression [, separator [, number [, start position]): returns a zero-dimensional array,
Contains a specified number of substrings
Note:
Delimiter: (optional) character used to identify the substring boundary. If omitted, use space as
Is a separator. If delimiter is a zero-length string
Single-element array of strings
The number and start position are not described
Join (string expression [, separator]): concatenates a series of strings into one string and uses Separators
Separator. If the separator is omitted, space characters will be used. Generally, the string expression is just an array
Name
Lcase (): replace all strings with lowercase letters.
Ucase (): replace all strings with uppercase letters.
Instr (): returns the position of a string that appears for the first time in another string.
Format: instr ([start position,] string expression to be searched, string expression to be searched
Type [, whether to perform binary comparison])
Note:
No 0 is returned, and the function returns B, which is similar to the. B function above.
Binary comparison is performed by default.
Functions with different structures compared with this function: Faster Rev (), less useful and required
You can check the manual
StrComp (string1, string2 [, whether to perform binary comparison]): returns a string Ratio
Greater result value
Note:
If string1 is smaller than string2,-1 is returned;
If string1 is greater than string2, 1 is returned;
If string1 is equal to string2, 0 is returned;
If one of string1 or string2 is null, null is returned.
In addition, the default value is binary comparison. If the value is set to 1, text comparison is performed.
Common string processing functions:
Chr (), chrb (), chrw (), asc (), ascb (), and ascw ()
Space (): returns a string consisting of a specified number of spaces.
For example, Space (10) returns a string consisting of 10 spaces.
String (length, string): returns a String consisting of a specified length and repeated characters.
String
Note:
Length: returns the length of the string.
String: Specifies the character code of a character or String expression.
The first character is used to form the returned string. If the character parameter package
Null is returned.
For example:
Dim MyString
MyString = String (5, "*") 'returns "*****".
MyString = String (5, 42) 'returns "*****".
MyString = String (10, "ABC") 'returns "AAAAAAAAAA"
In addition:
If the specified string value is greater than 255, the String uses the following formula
Convert to valid character code:
String Mod 256.
StrReverse (string): returns a string in the opposite order of the specified string.
NOTE: If string is a zero-length string (""), a zero-length string is returned. If
If string is Null, an error occurs.
Example: MyStr = StrReverse ("VBScript") 'mystr contains "tpircSBV"