<< Click to Display Table of Contents >> Select Case (statement) |
Select Case Expression
[Case Value1
[Statements]]
[Case Value2
[Statements]]
.
.
.
[Case Else
[Statements]]
End Select
Executes one of several statement blocks, depending on the value of the given expression (see also the section Flow control).
A Select Case structure must be closed with End Select.
See also: If Then Else, section Flow control
Example:
Sub Main
Number = InputBox("Enter an integer number between 1 and 3:")
Select Case Val(Number)
Case 1
MsgBox "You entered the number One."
Case 2
MsgBox "You entered the number Two."
Case 3
MsgBox "You entered the number Three."
Case Else
MsgBox "Only the integer values between 1 and 3 are allowed!"
End Select
End Sub