Quick check of VBScript grammar and its illustration

Source: Internet
Author: User
Tags abs date array chr empty expression include variable
vbscript| Syntax |vbscript

VBScript functions
Function description
Example
ABS (value) absolute value. The absolute value of a number is its positive value. The absolute value of an empty string (null), also an empty string. Uninitialized variables, which are absolutely 0 examples: ABS (-2000)
Results: 2000

Array (a comma-delimited array element) Array function returns the value of an array element. Example:
A=array (1,2,3)
B=a (2)
Results: 2
Description: Variable B is the value of the second element of array A.

ASC (String) converts the first letter of the string to ANSI (American National standard symbol) codewords. Example: ASC (Internet)
Results: 73
Description: Displays the ANSI codewords of the first letter I.


CBool (expression) conversion to Boolean logical value variable form (TRUE or FALSE) Example: CBool (1+2)
Result: True


The CDate (date expression) is replaced by a date variable type. You can use the IsDate function to determine whether a date could be converted. Example: CDate (now () +2)
Results: 2000/5/28 10:30:59


The CDBL (expression) is converted to a double variable type.


CHR (ANSI codewords) converts ASCII codewords to characters. Example: Chr (72)
Result: H


The CInt (expression) is converted to an integer variable form. Example: CInt ("3.12")
Results: 3


The CLng (expression) is converted to a long variable type.


The CSng (expression) is converted to a single variable type.


The CSTR (expression) is converted to a string variable type.


Date () Top returns the day of the system. Example: Date
Results: 2000/5/13
DATEADD (I, N, D) adds a date after a period of time. I: Set the unit for a period of time (date). For example, interval= "D" means the unit of n is the day. The setting value of I is as follows:
YYYY year
Q Quarter Season
M Month Month
D Day
W Weekday Week
H Hour Time
N-Minute
S Second sec
N: A numeric expression that sets a period of time added by a date, either positive or negative, positive (the result is >date date), and negative for minus (the result is >date previous date).
D: The date to be added and reduced. Example: DateAdd ("M", 1, "31-jan-98")
Result: 28-feb-98
Note: Add the date 31-jan-98 one months, the result is 28-feb-98 rather than 31-fe-98.
Example: DateAdd ("D", "30-jan-99")
Results: 1999/2/9
Description: Add a date 30-jan-99 20 days after the date.


DateDiff (I, D1, D2[,fw[,fy]) calculates the period between two dates.
I: Set the unit of the period calculation between two dates. For example, >i= "m" means the unit of calculation is month. >i setting values are as follows:
yyyy > Year
Q Quarter Season
M Month Month
D Day
W Weekday Week
H Hour Time
M-Minute
S Second sec
D1, D2: Two date expressions in the calculation period, if >date1 earlier, the period result between two dates is positive; if >date2 earlier, the result is negative.
FW: Sets the first day of the week for the week, if not set for Sunday. The set values for >FW are as follows:
0 Use the set value of >api.
1 Sunday
2 Monday
3 Tuesday
4 Wednesday
5 week Four
6 Friday
7 Saturday
FY: Setting the first week of the year, if not set, means that the week of January 1 is the first week of the year. The set values for >fy are as follows:
0 Use the set value of >api.
1 January 1 The week is the first week of the year
2 include at least four days of the first week of the first week of the year
3 includes the first week of seven days as the first week of the Year: DateDiff ("D", "25-mar-99", "30-jun-99")
Results: 97
Description: Displays the period between two dates as 97 days.
DatePart (I,d,[,fw[,fy]) returns the part of a date.
>i: Set it back to that part. For example, >i= "D" means to return part of the day. The set values for >i are as follows:
YYYY year
Q Quarter Season
M Month Month
D Day
W Weekday Week
H Hour Time
M-Minute
S Second sec
D: the date to be calculated.
>FW: Set the first day of the week for the weekday, if not set for Sunday. The set values for >FW are as follows:
0 Use the set value of >api.
1 Sunday
2 week one >3 Tuesday
4 Wednesday
5 week Four
6 Friday
7 Saturday
FY: Setting the first week of the year, if not set, means that the week of January 1 is the first week of the year. The set values for >fy are as follows:
0 Use the set value of >api.
1 January 1 The week is the first week of the year
2 include at least four days of the first week of the first week of the year
3 includes the first week of seven days as the first week of the Year: DatePart ("M", "25-mar-99")
Results: 3
Description: Displays the month part that returns a date.


Dateserial (year,month,day) conversion (Year,month,day) into a date variable type. Example: DateSerial (99,10,1)
Results: 1999/10/1


The DateValue (string or expression of the date) is converted to a date variable type, dated from January 1,100 to December 31,9999. The format is Month,day,and year or month/day/year. For example: December 30,1999, Dec 30,1999, 12/30/1999, 12/30/99 Examples: DateValue ("January 1,2002")
Results: 2002/1/1


Day (the string or expression of the date) returns the "days" part of the date. Example: Day ("12/1/1999")
Results: 1


The Fix (expression) top conversion string is an integer numeric form. Same as Int function. NULL is returned if NULL.
The difference between Int (number) and Fix (number) is negative. such as Int ( -5.6) =-6, Fix (-5.6) =-5. Example: Fix (5.6)
Results: 5
Hex (expression) top returns the hexadecimal value of a value. If the expression is null Hex (expression) =null, if the expression =empty Hex (expression) = 0. The 16 carry can be added "&h", for example, the 16 carry &H10 represents the decimal 16. Example: Hex (30)
Results: 1E


Hour (a string or expression of time) returns the "hour" portion of the time. Example: Hour ("12:30:54")
Results: 12


INSTR ([Start,]string1,string2[,compare]) top returns a string from the left and right to the other, returning to the same position as the first.
Start is a comparison from the first word, if you omit start

[1] [2] [3] Next page



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.