Features
Ask DevGuru
ASP Resources
Find the Bug
Knowledge Base
Links
Tips of the Week
Tutorials
Products
dgCalendar
dgCharge New!
dgChart New!
dgFileUpload
dgReport New!
dgSort
dgTree
Site
Authoring
Coming Soon
DevGuru Resume
Link to Us
Merchandise
Sponsorships
Testimonials
What's New
Technologies
ADO 2.6
ASP
CSS2
HTML
JavaScript
Jet SQL
Transact-SQL Syntax
VBScript
WML
WMLScript
WSH
XML DOM
All Statements
STATEMENT: If  ... Then  ... Else
Implemented in version 1.0
If
. . .
Then
The
If
conditional statement executes groups of statements only when a single test condition is
True
.
You can place
If
statements inside of other conditional statements. You must end all
If
statements with
End If
or you will get an error message. Also, the
Then
must be on the same line as the
If
.
Code:
<%
If mydate = "6/26/1943" Then
Rem You can place any code you desire here
End If
%>
Code:
<%
If somenumber < 71 Then
Rem You can place any code you desire here
End If
%>
If
. . .
Then
. . .
Else
The
If
part of the
If ... Else
statement conditionally executes groups of statements only when a single test condition is
True
.
The
Else
part of the
If ... Else
statement conditionally executes groups of statements only when the test
If
condition is
False
.
You can place
If ... Else
statements inside of other conditional statements. You must end all
If ...Else
statements with
End If
or you will get an error message. Also, the
Then
must be on the same line as the
If
.
Code:
<%
If somenumber < 71 Then
Rem You can place any code you desire here
Else
Rem You can place any code you desire here
End If
%>
If
. . .
Then
. . .
ElseIf
The
If ... ElseIf
statements allows you to test multiple conditions.
The
If
part of the
If ... ElseIf
statement conditionally executes groups of statements only when the test condition is
True
.
The
ElseIf
part of the
If ... ElseIf
statement conditionally executes groups of statements only when the test
If
condition is
False
and the test condition for that specific
ElseIf
part is
True
.
You can place
If ... ElseIf
statements inside of other conditional statements. You must end all
If ...ElseIf
statements with
End If
or you will get an error message. Also, the
Then
must be on the same lines as the
If
and the
ElseIf
.
Code:
<%
If somenumber < 43 Then
Rem You can place any code you desire here
ElseIf somenumber < 77 Then
Rem You can place any code you desire here
ElseIf somenumber < 94 Then
Rem You can place any code you desire here
End If
%>
Code:
<%
If somenumber < 43 Then
Rem You can place any code you desire here
ElseIf somenumber < 77 Then
Rem You can place any code you desire here
ElseIf somenumber < 94 Then
Rem You can place any code you desire here
Else
Rem You can place any code you desire here
End If
%>
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information