</>
Skip to content
ASP lessons (8/40)

ASP — Conditions

If...Then

<%
Dim age
age = 25

If age >= 18 Then
    Response.Write("Adult")
End If
%>

If...Then...Else

<%
Dim age
age = 15

If age >= 18 Then
    Response.Write("Adult")
Else
    Response.Write("Minor")
End If
%>

ElseIf

<%
Dim score
score = 85

If score >= 90 Then
    Response.Write("A")
ElseIf score >= 80 Then
    Response.Write("B")
ElseIf score >= 70 Then
    Response.Write("C")
Else
    Response.Write("F")
End If
%>

Select Case

<%
Dim day
day = "Monday"

Select Case day
    Case "Monday"
        Response.Write("Start of week")
    Case "Friday"
        Response.Write("End of week")
    Case Else
        Response.Write("Midweek")
End Select
%>

Nested If

<%
If age >= 18 Then
    If hasID Then
        Response.Write("Can enter")
    Else
        Response.Write("Need ID")
    End If
Else
    Response.Write("Too young")
End If
%>

Mini Practice

  1. Use If...Then
  2. Use If...Else
  3. Use ElseIf
  4. Use Select Case

Up Next

Continue with Loops — loop constructs.

Related Topics

Frequently Asked Questions about Conditions

What is Conditions in ASP?

Conditions is a fundamental concept in ASP. This lesson explains it step by step with clear examples, making it easy for beginners to understand.

How do I learn Conditions?

Start by reading the explanation above, then try the code examples. Practice by modifying the examples and experimenting with different values. Hands-on practice is the best way to learn Conditions.

Why is Conditions important in ASP?

Conditions is essential for ASP development. Understanding this concept will help you write better code and solve real-world problems more effectively.