If Then
The If Then... control flow statement allows you to create conditional
programming. This means you can evaluate a condition and depending on whether
it is true or false process one set of code or another.
In it's simplest form, you can simply put an If Then in front of a
statement (on the same line) to tell the ASP script engine to evaluate the
statement only if the condition is true. An example is shown below:
If (Day(Now()) = 1) Then Response.Write "It's the First of the Month"
You can create a whole code block that will be evaluated conditionally
by placing the code on a separate line from the If Then statement.
In this form, you have to terminate your code block with the End If
statement as shown below:
If (Day(Now()) = 1) Then Response.Write "It's the First of the Month" bFirstDay = True End If
With the Else statement, you can create two separate statements, one
of which will be executed depending on if the condition evaluates to
True or False. All of this can be placed on one line like in
the following example:
If (Day(Now()) = 1) Then bFirstDay = True Else bFirstDay = False
And just like the multi-line example above, you can create code blocks that
execute for both cases of the If Then Else statement. Don't forget to
include the terminating End If statement.
If (Day(Now()) = 1) Then Response.Write "It's the First of the Month" bFirstDay = True Else Response.Write "It's NOT the First of the Month" bFirstDay = False End If
|
 |

|