(1) Operators
1. The + operator can be used to connect strings.
Fullname = firstname + "" + lastname
However, we recommend that you use the & operator & dedicated to string connection.
Fullname = firstname & "& lastname
2. arithmetic operators:
^ Power
/Division
\ Division
MoD Division
3. Comparison operators:
= Equal to 'vb, the "Equal" operator of the logical operation and the value assignment use the same operator
<> Not equal
Is object equal
4. logical operators:
Not Inverse
And logic and
Or logic or
XOR exclusive or (different)
Eqv equality (Same) False eqv false = true
IMP contains (the same value or the second value is true)
(2) automatic type conversion
Number +/-string (string) if the string represents a number, convert it to a number and the result is also a number. Otherwise, an error is returned.
Date/time +/-the integer part of the number is used as the sum of the number of days and the date. The fractional part is used as the sum of the Time Offset and the number of days,
As a decimal part of a day (1 S = 0.0000115741; 12 h = 0.5)
Date +/-string if a string represents a number, it is converted to a number and the result is a date. Otherwise, an error is returned.
Convert values of any type to strings of any type and connect strings
(3) Process Control
1. If... then statement
IfConditionThen
...
ElseifOtherconditionThen
...
Else
...
End if
2. Select case statement
Select caseVariable
CaseValue: Statements
CaseValue:
Statements
...
End select
'Value can be a variable. When variable meets multiple values, only the first matching case statement is executed.
3. Do WHILE LOOP
1) do whileCondition
Statements
Loop
2) DoCondition
Statements
Loop
3) do
Statements
Loop whileCondition
4) do
Statements
LoopCondition
5) 'end from inside the loop
'Use the exit do statement
Do
Statements
IfConditionThen exit do
Statements
Loop
While form (1), 3): loop when condition is true;
Until form (2), 4): loop when condition is fasle;
Do first (3), 4): execute a statement at least once regardless of the condition.
4. For... next statement count
1)Counter=StartvalueToEndvalue
Statements
...
Next
2)Counter=StartvalueToEndvalueStepStepvalue
Statements
...
Next
'StepvalueIt can be a negative value.
5. Use for each to process collections and Arrays
Collection variable type: A list of file names, user names, or other data contained in a single variable.
The difference between a set and an array (from the http://blog.sina.com.cn/s/blog_5b7bfe100100mt2t.html ):
The set can be expanded as needed, unlike the array size. You can insert or delete an element into or from a collection. The collection can be automatically processed.
Except for arrays of the variant type, Arrays can only store the data types specified during declaration. However, different types of data can be stored in the same set.
Although you do not know the position of the element, you can quickly access the elements in the set through the subject word, or you can read the element value by the element serial number in the array method, which is flexible.
The modification of the Set element is not as convenient as that of the array element. You must delete it before adding it.
Processing a set is much slower than processing an array.
1) set FSO = Createobject ("scripting. FileSystemObject ")
Set tempfiles = FSO. getfolder ("C: \ Temp"). Files
Filelist = ""
For each file in tempfiles
Filelist = filelist & "," & file. Name
Next
Msgbox "the temp files are:" & filelist
2) dim Names [10]
...
For each NM in names
...
Next
VBScript learning notes-Key Points of basic syntax (1)