TechnologyUK - Programming (VB6) Logo

Logical Operators

Logical operators are used in conditional statements to test whether one or more expressions are TRUE or FALSE.



The AND Operator

AND is used to test whether two expressions both evaluate to TRUE, as shown below:

Condition1 AND Condition2

This statement equates to TRUE only if both Condition1 AND Condition2 are TRUE. This can be illustrated using the following truth table:


Truth Table for AND Operator
Condition1Condition2Condition1 AND Condition2
FALSEFALSEFALSE
FALSETRUEFALSE
TRUEFALSEFALSE
TRUETRUETRUE




The OR Operator

OR is used to test whether at least one of two expressions evaluates to TRUE, as shown below:

Condition1 OR Condition2

This statement equates to TRUE if either Condition1 or Condition2 (or both) is TRUE. This can be illustrated using the following truth table:


Truth Table for OR Operator
Condition1Condition2Condition1 OR Condition2
FALSEFALSEFALSE
FALSETRUETRUE
TRUEFALSETRUE
TRUETRUETRUE