Home » Programming » 06 - Statement Level Control Structures
6

Alternation

Alternation is having a selection of multiple statements to execute.

Alternation is having a selection of multiple statements to execute. It also includes the execution of an optional statement. With alternation, you have the ability to choose from several different execution paths in a program. These several different paths act like a set of branches. Alternation is usually referred to as having branch statements. This feature allows flexibility for your program. The path chosen in the program is based on a set of conditions. These conditions are usually Boolean conditions or relational conditions.

Alternation inctructs the computer to do certain tasks under certain conditions. The computer is given a set of actions or "alternatives" whenever certain scenarios arise. Both the "If" statements and the "Case" statements follow this kind of structure.

The “If” statements are conditional statements that are used in order to have multiple selections. The “If” statements are followed by the “Then” statement. The “Else” statement is used to have many more paths to choose from. The structure follows this pattern in most programming languages. “If condition holds then statement else statement else statement else statement end if.”

The “Case” statement is also similar to the “If” statements. The “Case” statements normally follow this pattern in most programming languages, “Case expression is when value when value when value when value end case.”

Try using the Case Select structure in your Visual Basic Editor. Below is an example of how the Case Select can be used.