Last updated: August 25, 2026.
Classic ASP commonly uses VBScript’s If...Then...Else and Select Case statements to choose which code runs. Use If for unrelated Boolean conditions and Select Case when several branches compare one expression.
If…Then…Else
<%@ Language="VBScript" %>
<%
Dim result
result = 70
If result >= 57 Then
Response.Write "Pass"
Else
Response.Write "Fail"
End If
%>ElseIf for several conditions
VBScript evaluates the conditions from top to bottom and executes the first matching branch.
<%
If result >= 75 Then
Response.Write "Grade A"
ElseIf result >= 60 Then
Response.Write "Grade B"
ElseIf result >= 45 Then
Response.Write "Grade C"
Else
Response.Write "Not passed"
End If
%>Select Case
<%
Dim flower
flower = "rose"
Select Case LCase(flower)
Case "rose"
Response.Write "Rose costs $2.50"
Case "daisy"
Response.Write "Daisy costs $1.25"
Case "orchid"
Response.Write "Orchid costs $1.50"
Case Else
Response.Write "Flower not found"
End Select
%>VBScript does not need a break after each Case. It exits the Select Case statement after executing the matching branch.
Ranges and multiple values
<%
Select Case score
Case 90 To 100
grade = "A"
Case 80 To 89
grade = "B"
Case 70, 71, 72
grade = "C-"
Case Is < 70
grade = "Needs improvement"
End Select
%>Practical guidance
- Convert request values to the expected type before comparing them.
- Keep the most specific
ElseIfconditions first. - Use
Case Elseto handle unexpected values. - Do not use a conditional as a substitute for authorization checks performed near protected operations.