Professional Documents
Culture Documents
B VBScript03
B VBScript03
Session 3
Dani Vainstein 1
What We learn Last seasson?
Dani Vainstein 2
Subjets for Session 3
Const Statement.
Operators.
Arithmetic.
Comparision.
Logical.
Dani Vainstein 3
Constants
Const Statement
Dani Vainstein 4
Constants
Const Statement
Dani Vainstein 5
VBScript Operators
VBScript has a full range of operators, including
arithmetic operators, comparison operators,
concatenation operators, and logical operators.
When several operations occur in an expression, each
part is evaluated and resolved in a predetermined order
called operator precedence.
You can use parentheses to override the order of
precedence and force some parts of an expression to be
evaluated before others.
Operations within parentheses are always
performed before those outside.
Dani Vainstein 6
VBScript Operators
Dani Vainstein 7
VBScript Operators
Arithmetic Operators
Exponentation operator
Symbol : ^
Description: Raises a number to the power of an exponent.
Syntax: result = number^exponent
Note: If either number or exponent is a Null expression, result is also Null.
Substraction operator
Symbol : -
Description: Finds the difference between two numbers or indicates the
negative value of a numeric expression.
Syntax: result = number1-number2 : -number
Note: If one or both expressions are Null expressions, result is Null. If an
expression is Empty, it is treated as if it were 0.
Dani Vainstein 8
VBScript Operators
Arithmetic Operators
Multiplication operator
Symbol : *
Description: Multiplies two numbers.
Syntax: result = number1*number2
If one or both expressions are Null expressions, result is Null. If an
expression is Empty, it is treated as if it were 0.
Division operator
Symbol : /
Description: Divides two numbers and returns a floating-point result.
Syntax: result = number1/number2
Note: If one or both expressions are Null expressions, result is Null. If an
expression is Empty, it is treated as if it were 0.
Dani Vainstein 9
VBScript Operators
Arithmetic Operators
Dani Vainstein 10
VBScript Operators
Arithmetic Operators
Dani Vainstein 11
VBScript Operators
Arithmetic Operators
Addition operator
Symbol : +
Description: Sums two numbers.
Syntax: result = number1+number2
Note: Although you can also use the + operator to concatenate
two character strings, you should use the & operator for
concatenation to eliminate ambiguity and provide self-documenting
code.
Dani Vainstein 12
VBScript Operators
Arithmetic Operators
Concatenation operator
Symbol : &
Description: Forces string concatenation of two expressions.
Syntax: result = expression1 & expression2
Notes: Whenever an expression is not a string, it is converted to a String
subtype.
If both expressions are Null, result is also Null.
However, if only one expression is Null, that expression is treated as a zero-
length string ("") when concatenated with the other expression.
Any expression that is Empty is also treated as a zero-length string.
Dani Vainstein 13
VBScript Operators
Comparision Operators
Dani Vainstein 14
VBScript Operators
Logical Operators
True False
False True
Null Null
Dani Vainstein 15
VBScript Operators
Logical Operators
Dani Vainstein 17
VBScript Operators
Logical Operators
Dani Vainstein 18