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. Within parentheses, however, standard operator precedence is maintained.
Arithmetic | Comparison | Logical |
---|---|---|
Negation (-) | Equality (=) | Not |
Exponentiation (^) | Inequality (<>) | And |
Multiplication and division (*, /) | Less than (<) | Or |
Integer division (\) | Greater than (>) | Xor |
Modulus arithmetic (Mod) | Less than or equal to (<=) | Eqv |
Addition and subtraction (+, -) | Greater than or equal to (>=) | Imp |
String concatenation (&) | Is | & |
When multiplication and division occur together in an expression, each operation is evaluated as it occurs from left to right. Likewise, when addition and subtraction occur together in an expression, each operation is evaluated in order of appearance from left to right.
The string concatenation (&) operator is not an arithmetic operator, but in precedence it falls after all arithmetic operators and before all comparison operators. The Is operator is an object reference comparison operator. It does not compare objects or their values; it checks only to determine if two object references refer to the same object.