XLS Padlock Guide
XLS Padlock Guide

If statements

 

 

VBA Code Protection > Supported VBA syntax by compiler > If statements

 

There are two forms of if statement: if...then..end if and the if...then...else..end if. Like normal basic, if the if expression is true, the statements are executed. If there is else part and expression is false, statements after else are executed.

 

Examples:

 

 
IF J <> 0 THEN
 Result = I/J
END IF
 
IF J = 0 THEN
 Exit
ELSE
 Result = I/J
END IF
 
IF J <> 0 THEN
   Result = I/J
   Count = Count + 1
ELSE
   Done = True
END IF
 

If the IF statement is in a single line, you don't need to finish it with END IF:

 

IF J <> 0 THEN Result = I/J
IF J = 0 THEN Exit ELSE Result = I/J

while statements