As mentioned in the introduction, If commands can be added to your code to make your program execute different code based on different values of expressions. It allows you to either execute one sequence of commands on occaision, or to select one of two possible sequences of commands. There are two basic forms that the command can take. The first is:
In this case, if the value of the Expression evaluates to true, the command following the Then will be performed. However, if the expression evaluates to false, the command after the Else will be performed (if it is included - this part is optional).
It is even possible to use more If statements in place of the commands which come after the Then or Else keywords.
The second style of using the If statement is as follows:
Notice there is no Then keyword in this mode. It is also possible to use "End If" (with a space). Similar to the first mode, if the value of the expression is true then the first set of commands will be performed. If the value of the expression is false, then the alternate set of commands are carried out. The Else keyword and alternate commands are optional again. Here is an example of using the If structure in the second way:
Installation | Troubleshooting | Programming | Archives | Links
Page last modified: 17th March 2002