Logical Operators

You use the logical operators to combine or modify true/false expressions. Table 4.3 summarizes VBAs logical operators. I provide more detail about each operator later in this chapter (see "Working with Logical Expressions").

Table 4.3

The VBA Logical Operators

Operator

General Form

What It Returns

And

Exprl And Expr2

True if both Exprl and Expr2 are true; False otherwise.

Or

Exprl Or Expr2

True if at least one of Exprl and Expr2 are true; False otherwise.

Xor

Exprl Xor Expr2

False if both Exprl and Expr2 are true or if both Exprl and Expr2 are false; True otherwise.

Not

Not Expr

True if Expr is false; False if Expr is true.

0 0

Post a comment