An Interactive Learning Tool

Proud to be a Teacher


Select Case

When you need to execute a group of statements depending upon a value of an Expression, then Switch Case is used. Each value is called a Case, and the variable is being switched ON based on each case. Case Else statement is executed if the test expression doesn't match any of the Case specified by the user.
Case Else is an optional statement within Select Case, however, it is a good programming practice to always have a Case Else statement.


Following is the syntax of a Switch statement in VBScript.
Select Case expression


For demo purpose, let us find the type of integer with the help of a function.

When the above code is executed, it produces the following result.

Select case can be used for many more functions where you suppose a switching is required.

Terms of use Website Policy Contact us
© Copyrights 2020