ÄúµÄλÖãºÑ°ÃÎÍøÊ×Ò³£¾±à³ÌÀÖÔ°£¾VBScript£¾VBScript


objects constants operators statements functions properties methods







STATEMENT:  Select Case

Select Case

The Select Case conditional statement selectively executes different groups of code by comparing a variable to a series of conditions. You may specify multiple, comma-delimited conditions for each Case as in the first example below.

If there is a match, then the Case is skipped over and the next Case is considered, and so on for each Case.

You must end the Select Case statement with End Select or you will get an error message.

Code:
<%
Select Case finalnumber
Case 1, 5
   result = "The result is 1 or 5"
Case 2
   result = "The result is 2"
Case 3
   result = "The result is 3"
End SELECT %>

The Case Else statement is optional and will only execute if none of the other conditions match.

Code:
<%
Select Case firstname
Case "Brenn"
   Welcome = "Hello Brenn"
Case "Fred"
   Welcome = "Hello Fred"
Case "Susan"
   Welcome = "Hello Susan"
Case Else
   Welcome = "Hello world"
End Select %>