Select Case
Select Case does a similar job to If..Then..Else..
Below is an example using a variable called Name. Depending on whether
Name equals Michael, Gavan, Fred or none of these names a different
line of code is run.
<%
SELECT CASE Name
Case Michael
Response.write Name is Michael
Case Fred
Response.write Name is Fred
Case Gavan
Response.write Name is Gavan
Case Else
Response.write "The name is something else"
END SELECT
%>
The above example applies to text. The example below applies to a number.
<%
SELECT CASE Number
Case 1
Response.write Number is equal to 1
Case 2
Response.write Number is equal to 2
Case 3
Response.write Number is equal to 3
Case Else
Response.write "The number is not equal to any of the values
above "
END SELECT
%>
(Read the second part of this tutorial that will introduce posting
form variables and provide a slightly more complicated example select
case.)
Site developed by Michael Wall - Web Design Belfast N.Ireland.
Copyright © 2000-2008. All rights reserved.
|