Codefixer - ASP tutorials, resources and software
asp.netPRO “Best ASP.NET Host” – DiscountASP.NET
Home   Articles   Resources   ASP directory   ASP Tutorials   Code Snippets   ASP Applications   Forum
Monday 12 May
MembersPro PayPal - ASP Membership software

ASP.NET 3.5 Hosting – DiscountASP.NET


ASP Partner ASP Partner ASP Partner more partners...

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”
'It is possible that none of the case statements equal the value of variable Name
'so in this scenario - use Case Else
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”
'It is possible that none of the case statements equal the value of variable Number
'so in this scenario - use Case Else
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.)

LinksPro - Directory  and Link  Management Software




ASP.NET 3.5/2.0 Web Hosting: 3 Months FREE – Click Here!




About | Contact | Advertise | Feedback | Hire Us | Link

Site developed by Michael Wall - Web Design Belfast N.Ireland.
Copyright © 2000-2008. All rights reserved.

Do you intend to move to ASP.NET or have you already?
Yes will do
Have done
ASP does fine
Not a priority


Directory Software