VBScript Functions
Function Description
Example
Abs (numerical value) absolute value. The absolute value of a number is its positive value. The absolute value of a null string. The uninitialized variable is definitely 0. Example: ABS (-2000)
Result: 2000
Array (an Array element separated by commas) the Array function returns the value of an Array element. Example:
A = Array (1, 2, 3)
B = A (2)
Result: 2
Note: Variable B is the value of the second element of array.
Asc (string) converts the first letter of the string into an ANSI (American National Standard) character code. Example: Asc (Internet ")
Result: 73
Description: displays the ANSI code of the first letter I.
Example: CBool (1 + 2)
Result: True.
CDate (date expression) is changed to the date variable type. You can use the IsDate function to determine whether the data can be converted to a date. Example: CDate (now () + 2)
Result: 10:30:59
CDbl (expression) is converted to the DOUBLE variable type.
Chr (ANSI code) converts ASCII code into characters. Example: Chr (72)
Result: H
CInt (expression) is converted to an integer variable type. Example: CInt ("3.12 ")
Result: 3
CLng (expression) is converted to the LONG variable type.
CSng (expression) is converted to the SINGLE variable type.
CStr (expression) is converted into a string variable type.
Date () top returns the Date of the system. Example: Date
Result: 2000/5/13
DateAdd (I, N, D) adds a date after a period. I: Set the unit of a period added by a Date. For example, interval = "d" indicates that the unit of N is day. I is set as follows:
Yyyy Year
Q Quarter
M Month
D Day
W Weekday
H Hour
N Minute points
S Second seconds
N: a numeric expression that specifies the period of a date. It can be a positive or negative value. A positive value indicates a plus (the result is a date after date ), negative value indicates subtraction (Result:> date before date ).
D: Date to be added or subtracted. Example: DateAdd ("m", 1, "31-Jan-98 ")
Result: 28-Feb-98
Note: if the date is 31-Jan-98 plus one month, the result is 28-Feb-98 rather than 31-Fe-98.
Example: DateAdd ("d", 20, "30-Jan-99 ")
Result:
Note: Add a date of 30-Jan-99 plus a date of 20 days.
DateDiff (I, D1, D2 [, FW [, FY]) calculates the period between two dates.
I: Set the unit of Period Calculation between two dates. For example, I = "m" indicates that the unit of calculation is month. > The Set Value of I is as follows:
Yyyy> Year
Q Quarter
M Month
D Day
W Weekday
H Hour
M Minute
S Second seconds
D1, D2: Two date expressions in the calculation period. If> date1 is earlier, the period result between two dates is positive. If> date2 is earlier, the result is negative.
FW: set the first day of each week to the day of the week. If not set, it indicates Sunday. > The FW settings are as follows:
0 usage> API setting value.
1 Sunday
2 Monday
3 Tuesday
4. Wednesday
Friday
6 Friday
7. Saturday
FY: set the first week of the year. If not specified, the week of January 1, January 1 is the first week of the year. > The FY value is as follows:
0 usage> API setting value.
1. The week of January 1, January 1 is the first week of the year.
2. The first week of at least four days is the first week of a year.
3 Example of the first week of a year in seven days: DateDiff ("d", "25-Mar-99", "30-Jun-99 ")
Result: 97
Note: The period between two dates is 97 days.
DatePart (I, D, [, FW [, FY]) returns the part of a date.
> I: Set the part to be returned. For example,> I = "d" indicates that the return part is a day. > I is set as follows:
Yyyy Year
Q Quarter
M Month
D Day
W Weekday
H Hour
M Minute
S Second seconds
D: Date to be calculated.
> FW: Specifies the day of the week on the first day of the week. If not specified, it indicates Sunday. > The FW settings are as follows:
0 usage> API setting value.
1 Sunday
2 Monday> 3 Tuesday
4. Wednesday
Friday
6 Friday
7. Saturday
FY: set the first week of the year. If not specified, the week of January 1, January 1 is the first week of the year. > The FY value is as follows:
0 usage> API setting value.
1. The week of January 1, January 1 is the first week of the year.
2. The first week of at least four days is the first week of a year.
3 Example of the first week of a year in seven days: DatePart ("m", "25-Mar-99 ")
Result: 3
Description: displays the monthly part of a date.
Dateserial (year, month, day) is converted into a date variable type. Example: DateSerial (99,10, 1)
Result:
DateValue (string or expression of the date) is converted to the date variable type, with the date from January 1,100 to December 31,9999. The format is month, day, and year or month/day/year. Example: December 30,1999, Dec 30,1999, 12/30/1999, 12/30/99: DateValue ("January ")
Result: 2002/1/1
Day (a string or expression of the date) returns the "Day" part of the date. Example: Day ("12/1/1999 ")
Result: 1
Fix (expression) top converts a string to an integer numeric state. Same as Int function. If it is null, null is returned.
The difference between Int (number) and Fix (number) is negative. For example, Int (-5.6) =-6, Fix (-5.6) =-5. Example: Fix (5.6)
Result: 5
Hex (expression) top returns the hexadecimal value of the value. If the expression is null, Hex (expression) = null. If the expression is Empty, Hex (expression) = 0. "& H" can be added to the hexadecimal notation. For example, "16-digit" & H10 "indicates the hexadecimal notation of 16. Example: Hex (30)
Result: 1E
Hour (a time string or expression) returns the Hour part of the time. Example: Hour ("12:30:54 ")
Result: 12
InStr ([start,] string1, string2 [, compare]) top compares a string from left to right with another string and returns the first string at the same position.
Start indicates the number of characters to be compared. If start is omitted, start indicates the first word to be compared. string1 indicates the string expression to be searched, and string2 indicates the string expression to be compared, compare is the comparison method, compare = 0 table binary comparison method, compare = 1 Table text comparison method, if compare is omitted, It is the preset binary comparison method. Example: InStr ("abc123def123", "12 ")
Result: 4
Limit Rev ([start,] string1, string2 [, compare]) compares a string from right to left with another string and returns the first string at the same position.
Start indicates the number of characters to be compared. If start is omitted, start indicates the first word to be compared. string1 indicates the string expression to be searched, and string2 indicates the string expression to be compared, compare is the comparison method, compare = 0 table binary comparison method, compare = 1 Table text comparison method, if compare is omitted, It is the preset binary comparison method. Example: Rev ("abc123def123", "12 ")
Result: 10
Int (expression) returns the integer part of a value. Same as the Fix function. Example: Int (5.6)
Result: 5
The IsArray (variable) test variable is (True) No (False) is an array. Example: IsArray (3)
Result: False.
Note: It is not an array.
Whether IsDate (Expression of date or string) can be converted to date. The date ranges from January 1,100 A.D. to December A.D. Example: IsDate ("December 31,1999 ")
Result: True.
Description: It can be converted to a date.
IsEmpty (variable) test variable is (True) No (False) has been initialized example: IsEmpty ()
Result: True.
The IsNull (variable) test variable is (True) No (False) not valid data. Example: IsNull ("")
Result: False.
Description: valid data.
IsNumeric (expression) is (True) No (False) is a number. Example: IsNumeric ("abc123 ")
Result: False.
Note: It is not a number.
LCase (string expression) top converts a string to lowercase. Converts the uppercase letters to lowercase letters. The rest of the string remains unchanged. Example: LCase ("ABC123 ")
Result: abc123
Left (string expression, length) takes the words on the Left of the string. Length is a word. The Len function can tell the length of the string. Example: Left ("ABC123", 3)
Result: ABC
Len (string expression variable) gets the length of the string. Example: Len ("ABC123 ")
Result: 6
LTrim removes the white space on the left of the string. RTrim removes the white space on the right of the string, and the Trim function removes the white space on both sides of the string. Example: LTrim ("456 +" abc ")
Result: 456abc123
Mid (string expression, start [, length]) top returns the characters in the string. Start is the number of characters starting from, and length is the number of words. If the length is slightly greater, it is obtained from start to the rightmost bottom. The Len function can tell the length of the string. Example: Mid ("abc123", 2, 3)
Result: c12
Minute (a date string or expression) returns the Minute part of the time. Example: Minute ("12:30:54 ")
Result: 30
Month (string or expression of the date) returns the Month of the date. Example: Month ("12/1/2001 ")
Result: 12
MonthName (month [, abbreviate]) returns the name of the month.
Month: Number 1 ~ 12. For example, 1 represents January, and 7 represents July.
Abbreviate: Yes (True) No (False) is short for March, or Mar. The default value is False. The Chinese month name has no abbreviation. Example: MonthName (7)
Result: February 1, July
Now () returns the date and time of the system. Example: Now ()
Result: 10:35:59 AM
Oct () returns the octal value of the value. "& O" can be added to carry 8. For example, carry 8 & O10 represents the decimal 8. Example: Oct (10)
Result: 12
Replace (string expression, findnreplacewith [, start [, count [, compare]) replaces a string with some words. Search for the original string to be replaced (find). If it is found, it is replaced with the new string (replacewith ).
Find: the original string to be replaced.
Replacewith: The replaced word.
Start: Search for replacement from the first word. If not specified, search for replacement from the first word.
Count: the number of replacement times. If not specified, all searched strings replace character strings.
Compare: The comparison method. compare = 0 indicates the binary comparison method, compare = 1 Table text comparison method, compare = 2 table depends on the Data Type of the comparison, if omitted
Compare is the default binary comparison method. Example: Replace ("ABCD123ABC", "AB", "AB ")
Result: abCD123abC
Right (string expression, length) is the Right character of the string, and length is the word. The Len function can tell the length of the string. Example: Right ("ABC123", 3)
Result: 123
Rnd [(number)] 0 ~ A random value of 1. Number is any valid numeric expression. If the number is smaller than 0, the same random value is obtained each time. If the number is greater than 0 or is not provided, the next random value is obtained in sequence. > Number = 0 indicates obtaining the most recent random value. To avoid the same random number order, you can add Randomize before the Rnd function. Example: Rnd
Result: 0.498498
Round (numeric expression [, D]) rounding.
D: number of decimal places rounded to. If not, rounded to an integer. Example: Round (30635,1)
Result: 3.6
RTrim removes the white space on the right of the string. LTrim removes the white space on the left side of the string. The Trim function removes the white space on both sides of the string. Example: RTrim ("abc123") + "456"
Result: abc123456
Second (string or expression of Time) top returns the "Second" part of the time. Example: Second ("12:30:54 ")
Result: 54
Space (repeated times) to obtain the same blank string. Example: A "+ Space (5) +" B
Result: A B
Note: Five blank words are added between A and B.
String (number of repetitions, the word to be repeated) to obtain the same repeated String. Example: String (5, 71)
Result: GGGGG
StrReverse (String () reverses the order of a String. Example: StrReverse ("ABC ")
Result: CBA
The Time when Time () is returned to the system. Example: Time
Result: 10:35:59
TimeSerial (hour, minute, second) converts the specified (hour, minute, second) to the time variable type. Example: TimeSerial (10, 31, 59)
Result: 10:31:59
TimeValue (a date string or expression) is converted to a time variable type. The string or expression of the date from 0:00:00 (12:00:00 a.m.) to 23:59:59 (11:59:59 p.m .). Example: TimeValue ("11:59:59 ")
Result: 11:59:59
Trim removes spaces on both sides of the string. Example: Trim ("abc123 ")
Result: abc123
UCase () top converts the string to uppercase. Converts the lower-case letters to uppercase, and the rest of the string remains unchanged. Example: UCase ("abc123 ")
Result: ABC123
VarType (variable) returns a variable type. Same as the TypeName function, VarType returns the code of the variable type, and TypeName returns the name of the variable type. Example: VarType ("I love you! ")
Result: 8
Weekday (date expression, [FW]) returns the number of the day of the week.
FW: set the first day of a week to the day of a week. If this parameter is omitted, table 1 (Sunday) is displayed ).
Firstdayfweek is set to: 1 (Sunday), 2 (Monday), 3 (Tuesday), 4 (Wednesday), 5 (Thursday), 6 (Friday), and 7 (Saturday ). Example: Weekday ("1/1/2000 ")
Result: 7
WeekDayName (W, A, FW) returns the name of the day of the week.
W: Yes (True) No (False) is the abbreviation. For example, March is abbreviated as Mar. The default value is False. The day of the week in Chinese is not abbreviated.
FW: set the first day of a week to the day of a week. If table 1 (Sunday) is omitted ). Specifies the name of the day of the week to be returned, which is the day of the week.
A: 1 (Sunday), 2 (Monday), 3 (Tuesday), 4 (Wednesday), 5 (Thursday), 6 (Friday), 7 (Saturday ). Example: WeekDayName ("1/1/2000 ")
Result: Saturday
Year () returns the Year of the date. Example: Year ("12/1/2000 ")
Result: 2000