Thursday, December 6, 2012

Use of boolean operators

During today's class, we went over the logical operators AND and OR. There is also a third logical operator, XOR.

AND
In order for AND to be true, both conditions must evaluate to TRUE as in

IF condition1 AND condition2 THEN
     ' BASIC code statements here will execute when
     condition1 AND condition2 evaluate to TRUE

END IF

Inclusive OR
In order for OR to be true, at least one condition must evaluate to TRUE as in

IF condition1 OR condition2 THEN
     ' BASIC code statements here will execute when
     condition1 OR condition2 OR
     both conditions evaluate to TRUE

END IF

Exclusive OR
In order for XOR to be true, only one condition may evaluate to TRUE as in

IF condition1 XOR condition2 THEN
     ' BASIC code statements here will execute when
     condition1 evaluates to TRUE AND
     condition2 evaluates to FALSE OR

     condition1 evaluates to FALSE AND
     condition2 evaluates to TRUE

END IF