MAIN MENU
Select Case....End Select
The select case structure has a similar function to an if then statement in that it is a decision statement.
In the following example, the value of "value" will control which if the Case statements will be executed. In this example, as value = 3, it will be the third case statement that will be executed.
<%
value = 3
Select Case value
Case 1
Response.write ("Value 1")
Case 2
Response.write ("Value 2")
Case 3
Response.write ("Value 3")
Case 4
Response.write ("Value 4")
Case 5
Response.write ("Value 5")
Case Else
Response write ("Value is higher than 5")
End Select
%>
Note also the "Case Else" which is executed for situations where none of the other statements are executed.
The following example illustrates where you can use a case statement to be executed for two situations. Case "Peter", "Paul" means that it will be executed for Peter or Paul.
<%
name=request.form("name")
Select Case name
Case "Peter", "Paul"
Response.write ("Hello, Peter or Paul")
Case "John"
Response.write ("Hello, John")
Case "Joe"
Response.write ("Hi, Joe")
Case Else
Response write ("I do not know you")
End Select
%>