Select ... Case

Conditionally execute a block of statements.

Syntax 
      Select Case TestExpression
         [Case ExpressionList
            [Statements-n]]...
         [Case Else
            [ElseStatements]]
      End Select

Key
   TestExpression  A numeric or String expression which will
                   determine which block of code is executed

   ExpressionList  Comma delimited list of expressions to compare/
                   match against TestExpression

   Statements-n    Statements to execute if a match is found.

   ElseStatements  Statements to execute if a match is not found.

Example

strPerson="Jasper"

select case strPerson
case "Alex" WScript.Echo "We found Alex"
case "Jasper" WScript.Echo "We found Jasper"
case "Helen" WScript.Echo "We found Helen"
end select

“The day soldiers stop bringing you their problems is the day you have stopped leading them. They have either lost confidence that you can help them or concluded that you do not care. Either case is a failure of leadership” ~ Colin Powell

Related:

If..Then - Conditionally execute a block of statements
While...Wend - Conditionally repeat a block of statements
Equivalent Powershell command: Switch - Multiple if statements


© Copyright SS64.com 1999-2013
Some rights reserved