Select-case usage in ASP
Execute one of several sets of statements based on the value of an expression.
Select Case testexpression
[Case expressionlist-n
[statements-n]] . . .
[Case Else expressionlist-n
[elsestatements-n]]
End Select
parameter
testexpression
Any numeric or string expression.
expressionlist-n
Required if Case appears. A delimited list of one or more expressions.
statements-n
One or more statements that are executed when testexpression matches any part of expressionlist-n.
elsestatements-n
One or more statements that are executed when testexpression does not match any part of the Case clause.
illustrate
If testexpression matches any Case expressionlist expression, the statements between this Case clause and the next Case clause, or for the final clause through End Select, are executed, and then control Will go to the statement after End Select. If testexpression matches expressionlist expressions in multiple Case clauses, only the first matching statement is executed.
Case Else is used to indicate that if no match is found between testexpression and the expressionlist of any other Case option, elsestatements are executed. Although not required, it is a good idea to place the Case Else statement within a Select Case block to handle unforeseen testexpression values. If no Case expressionlist matches testexpression and there is no Case Else statement, execution continues with the statement after End Select.
Select Case statements can be nested, and each nested Select Case statement must have a matching End Select statement.
The following example illustrates how to use the Select Case statement:
Dim Color, MyVar
Sub ChangeBackground(Color)
MyVar = lcase(Color)
Select Case MyVar
Case red document.bgColor = red
Case green document.bgColor = green
Case blue document.bgColor = blue
Case Else MsgBox Select another color
End Select
End Sub
two. Routines (judgment)
<%
dim money
money=request(money)
select case true
case money > 5
response.Write5
case else
response.Writeelse
end select
%>
three. routine
<%
select case request.querystring(su)
case 1,3,5,7,9
response.write singular
case 2,4,6,8
response.write even number
case else
response.write very complex numbers
end select
%>