Maddy
Maddy

Reputation:

How do you implement a select statement in VBScript?

Can anyone please tell me how to implement select statements in VBScript, similar to switch statement in C? It would be great if you provided some examples as I'm pretty new to VBScript. Thanks.

Upvotes: 1

Views: 6510

Answers (2)

ghostdog74
ghostdog74

Reputation: 342463

example only

 Select Case strMyVariable
      Case "One"     Wscript.Echo "1"
      Case "Two"     Wscript.Echo "2"
      Case "Three"   Wscript.Echo "3"
      Case Else      Wscript.Echo "Wrong"
 End Select

Upvotes: 0

Gary McGill
Gary McGill

Reputation: 27526

Select Case foo
    Case 1
       MsgBox "1"
    Case 2, 3
       MsgBox "2 or 3"
    Case Else
       MsgBox "Something else"
End Select

Upvotes: 10

Related Questions