Relational and Logical Operators

You make decisions in your VBA procedures by using conditional expressions inside the special control structures. A conditional expression is an expression that uses a relational operator (Table 5-1), a logical operator (Table 5-2), or a combination of both. When Visual Basic encounters a conditional expression in your program, it evaluates the expression to determine whether it is true or false. Table 5-1: Relational operators in VBA

Operator Description

= Equal to

> Greater than

< Less than

>= Greater than or equal to

<= Less than or equal to

Table 5-2: Logical operators in VBA Operator Description

AND All conditions must be true before an action can be taken.

OR At least one of the conditions must be true before an action can be taken.

0 0

Post a comment