Vbscript Part1
Vbscript Part1
What is VBScript
• obj
– Three letter prefix for the data type
• DescriptiveName
– A descriptive name for the variable
– First letter of each word in upper case
Literal Types
• Numeric
– 1
– 3.14
– 3E7
• Boolean
– True
– False
• Characters
– “Hello World”
– “123 Straw Lane”
– “43210”
• Date
– #07/21/2006#
– #Jan 6, 2008#
Variables
Dim variableName
+ Addition
- Subtraction, Negation
* Multiplication
/ Division
\ Integer Division
^ Exponent
Mod Modulo
Comparison
• Used to compare the value of two items
• Both operands must be of the same data type
• The result is a Boolean value
= Equality
<> Inequality
< Less than
> Greater than
<= Less than or equals
>= Greater than or equals
Logical
• Used to reduce Boolean values into a single Boolean
value
• Both operands must be Boolean values
• The result is a Boolean value
And Conjunction
Or Disjunction
Not Negation
Xor Exclusion
And Truth Table
• Conjunction
• Used when both conditions are required
Operand 1 Result
T F
F T
Xor Truth Table
• Exclusion
• Used when either condition should be different
If condition Then
statement(s)
End If
While condition
statement(s)
Wend
• Iterated Loop
• Favored because all the loop details are in the
definition statement
Function
Function functionName(parameter list)
statement(s)
functionName = value
End Function
• Comment liberally
• Use a naming convention
• Avoid mixing cases
• Indent your code