Microsoft Office Tutorials and References
In Depth Information
The Logical Operators
You use logical operators to manipulate logical (True/False) expressions. Most of the logical
operators combine two logical expressions into a single logical value. The logical operators are described
in Table 23.2.
TABLE 23.2
The Logical Operators
Operator
Example
Evaluation
And
X And Y
True if both X and Y are True; False otherwise.
Or
X Or Y
True if X or Y , or both of them, are True; False only if both X and Y are
False.
Xor (exclusive Or )
X Xor Y
True if X and Y are different (one True and the other False); False if
both are True or both are False.
Eqv (Equivalence)
X Eqv Y
True if X and Y are the same (both True or both False); False otherwise.
Imp (Implication)
X Imp Y
False only if X is True and Y is False; True otherwise.
Not
Not X
True if X is False, False if X is True.
The logical operators are often used in conjunction with the comparison operators. For example,
the following expression evaluates as True only if x is equal to 5 and y is not equal to 0:
(x = 5) And (y <> 0)
Operator Precedence and Parentheses
When an expression contains more than one operator, it may not always be clear how the
expression evaluates. For example, look at this expression:
20 / 4 + 6