Microsoft Office Tutorials and References
In Depth Information
Table 8-3: Operator Precedence
Order of Precedence
* and /
Multiplication and division
+ and -
Addition and subtraction
= , < , > , <= , >= , <>
In the statement that follows, x is assigned the value 10 because the multiplication operator has
a higher precedence than the addition operator.
x = 4 + 3 * 2
To avoid ambiguity, you may prefer to write the statement as follows:
x = 4 + (3 * 2)
In addition, VBA provides a full set of logical operators, shown in Table 8-4. For complete details
on these operators (including examples), use the VBA Help system.
Table 8-4: VBA Logical Operators
What It Does
Performs a logical negation on an expression.
Performs a logical conjunction on two expressions.
Performs a logical disjunction on two expressions.
Performs a logical exclusion on two expressions.
Performs a logical equivalence on two expressions.
Performs a logical implication on two expressions.
The following instruction uses the Not operator to toggle the gridline display in the active
window. The DisplayGridlines property takes a value of either True or False . Therefore,
using the Not operator changes False to True and True to False .
ActiveWindow.DisplayGridlines = _