Multiple-alternative selection structures - If ElseIf Else EndIf
IF Else End If Structure is useful only for 2 to 4 selections
Visual Basic provides serval Multiple -alternative selection structure
If
ElseIF
ElseIF
..
Else
End If
Designed to choose from several alternatives
Condition in multiple-alternative selection structure does not require true/false answer
Requires expression whose value determines which path is chosen
Example: Display message based on grades ranging from A to F
Multiple-alternative selection structures - The Select Case Structure
Ch5 Example 1 use IF - ElseIF- Else - EndIf multiple alternative selection structure. This structure may cause confusing if there are many paths.
The second multiple alternative selection structure - The Select Case Structure - is simpler and cleaner.
Select Case statement
Begins with Select Case, ends with End Select
Each case represents a different instruction path
Optional Case Else clause handles all values not covered by other Case paths
selectorExpression is evaluated to determine path