ASP Net Center.com
ASP Tutorials & Basics
Introduction
Variables & Arrays
Sub & Functions
If Statements
Case Statements
Loop Statements
Date Objects
Form Processing
Text File Objects
Database Access
Adding Record
Updating Record
Deleting Record
Virtual Includes
Cookies
E-mail
Server Variables
Creating Login Page

ASP Case Statements

Case statement can be used instead of if statement suitably when one condition could have multiple possibilities. Following example illustrates the use of case statement
<% Dim dat
dat=WeekDay(Date)
%>
<%
Select Case dat
  case 1
    response.write("Today is Sunday")
  case 2
    response.write("Today is Monday")
  case 3
    response.write("Today is Tuesday")
  case 4
    response.write("Today is Wednesday")
  case 5
    response.write("Today is Thursday")
  case 6
    response.write("Today is Friday")
    case 7
    response.write("Today is Saturday")
  end select
%>
Result:
Today is Saturday

This example is to show the use of case statement and there is better way to show the day of the week in asp.  The variable dat is set to the day of the week and it could have values from 1 to 7, 1 is Sunday and 7 is Saturday.  Case statement is used to display the day of the week according to the value of variable dat.

If Statements Loops