Using Conditional Statements
Select Case statement
Select Case: Executes one of several groups of statements, depending on the value of an expression.
Syntax:
Select Case testexpression
[Case expressionlist-n
[statements-n]] . . .
[Case Else expressionlist-n
[elsestatements-n]]
End Select
Example:
'Select Case
Colour =Ucase( Inputbox("Please enter the colour of your choice"))
Select Case Colour
Case "RED"
MsgBox "Colour selected is Red"
Case "BLUE"
MsgBox "Colour selected is Red"
Case "GREEN"
MsgBox "Colour selected is Red"
Case ELSE
MsgBox "Invalid Colour"
End Select
Select Case statement
Select Case: Executes one of several groups of statements, depending on the value of an expression.
Syntax:
Select Case testexpression
[Case expressionlist-n
[statements-n]] . . .
[Case Else expressionlist-n
[elsestatements-n]]
End Select
Example:
'Select Case
Colour =Ucase( Inputbox("Please enter the colour of your choice"))
Select Case Colour
Case "RED"
MsgBox "Colour selected is Red"
Case "BLUE"
MsgBox "Colour selected is Red"
Case "GREEN"
MsgBox "Colour selected is Red"
Case ELSE
MsgBox "Invalid Colour"
End Select
No comments:
Post a Comment