Sunday, June 5, 2016

Learn VB Script Part 6

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

No comments:

Post a Comment