Comparison Operators
Comparison Operator |
Meaning |
Example |
= |
Equal to |
1 = 1 is true, 1=2 is false |
<> |
Not equal to |
1 <> 1 is false, 1 <> 2 is true |
> |
Greater than |
1 > 1 is false, 1 > 2 is false, 2 > 1 is true |
< |
Less than |
1 < 1 is false, 1< 2 is true, 2 < 1 is false |
>= |
Greater than or equal to |
1 >= 1 is true, 1 >= 2 is false, 2 >= 1 is true |
<= |
Less than or equal to |
1 <= 1 is true, 1 <= 2 is true, 2 <= 1 is false |
Logical Operators
You can combine more than one conditions using logical operators.
Logical Operator |
Meaning |
Example |
And |
Only if both conditions are true, then the result is true. |
If [condition1] And [condition 2] |
Or |
If at least one condition is true, then the result is true |
If [condition1] Or [condition 2] |
Not |
Negation of the condition. If the condition is true, the result is false. If the condition is false, then the result is true. |
If Not [condition] |
Xor |
If one and only one of the conditions is true, then the result is true. If all conditions are either true or false, then the result is false. So, if all conditions are false, then the result is false. If all conditions are true, then the result is also false. |
If blnStake Xor blnBurger Then strCustomer = “Satisfied” End If If a customer is served with either a stake or a burger, she is happy. But if the customer is not served anything or both, then she is not happy. (too hungry or too full) |