Home  |  Latest News  |  Contribute  |  F.A.Q.  |  Account  |  Scripts | About
Search ASPNut:
 
ASP Reference
Server Variables
ASP Glossary
Related Sites

Free Components

HTML Reference
Web Colors
Entities
CSS Level 1
Encode/Decode
Glossary

Our Sponsors
ASP Nuke CMS
Free Auctions
PHP 5 Script
Funktastic Blog
ULost Directory
Team Task

 

 

 

 

 

 

 

 

 

 

 

 

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

Orvado Technologies

ASP Nuke CMS
Free Open Source
Content Manager
HomeFix Boards
Home Remodeling
Message Boards

Contact Us | Contribute | About | Site Map



"It is better to deserve honors and not have them than to have them and not deserve them." - Mark Twain

©2010 San Diego Web Design - Orvado Technologies, All Rights Reserved
ASP Nut provides articles and reference documentation for Active Server Page developers.