ASP Education - # Free Resource for Active Server Pages (ASP) Programming, ASP Tutorial, ASP Lessons, ASP Guide    

Small Business Appreciation Sale - 50% off select products + Free Domain!
    

                                                                

ASP - Introduction
ASP - Setup/ installation
ASP - Running
ASP - First Script
ASP - Syntax
ASP - VBScript
ASP - Javascript
ASP - Operators
ASP - If Statement
ASP - Select
ASP - Variable
ASP - Array
ASP - Session
ASP - Cookies
ASP - String
ASP Procedures
ASP Application
ASP #include
ASP Global.asa
ASP - Forms
ASP - Forms Get
ASP - Forms Post
ASP - Email Form
ASP - Object
ASP - Components
ASP - Comments

ASP - If Statement



Sometimes when we write code, we want to perform different actions for different decisions. We can use conditional statements in your code to do this. Conditional statements are the set of commands used to perform different actions based on different conditions.

To support this, VBScript provides a series of words that can be combined to perform validations. VBScript has 2 conditional statement constructions, available for us to use in your ASP pages: If...then...else and Select Case. Both perform in saw way the same task. To use them, we must be aware of what each does or cannot do so you would select the right one.

If ... Then ... Else Statement

The If Statement is a way to make decisions based on a variable or some other type of data. For example, you might have a script that checks if Boolean value is true or false or if variable contains number or string value.

Use the if statement to execute a statement if a logical condition is true. Use the optional else clause to execute a statement if the condition is false. The syntax for If statement looks as follows:



if condition then 
   statements_1
else 
   statements_2
end if

Condition can be any expression that evaluates to true or false. If condition evaluates to true, statements_1 are executed; otherwise, statements_2 are executed. statement_1 and statement_2 can be any statement, including further nested if statements.



You may also compound the statements using elseif to have multiple conditions tested in sequence. You should use this construction if you want to select one of many sets of lines to execute.



if condition_1 then
   statement_1
[elseif condition_2 then
   statement_2]
...
[elseif condition_n_1 then
   statement_n_1]
[else
   statement_n]
end if

Let's have a look at the examples. The first example decides whether a student has passed an exam with a pass mark of 66:



<%@ language="vbscript"%>
<%
Dim Result
Result = 82

if Result >= 66 then
    response.write("Pass <br />")
else
    response.write("Fail <br />")
end if
%>


Small Business Appreciation Sale - 50% off select products + Free Domain!
ASP Tutorial / ASP HOME
ASP Introduction, ASP Install, ASP Syntax, ASP Variables, ASP Procedures, ASP Forms, ASP CookiesASP Session, ASP Application, ASP #include, ASP Global.asa
ASP Objects
ASP Response, ,ASP Request, ASP Application, ASP Session, ASP Server, ASP Error, ASP FileSystem, ASP TextStream, ASP Drive, ASP File, ASP Folder, ASP Dictionary, ASP ADO
ASP Functions
ASP Response, ,ASP Request, ASP Application, ASP Session, ASP Server
ASP Components
ASP AdRotator, ASP BrowserCap, ASP Content Linking, ASP Content Rotator
ASP and AJAX
AJAX Intro, AJAX ASP, JAX Database
ASP Examples
ASP Examples, ASP Send e-mail, ASP Quiz, ASP Certificate
ASP Resources
ASP Quick Ref, ASP FAQs
ASP Summary
ASP Summary, etc

Custom Search
ASP - Special Characters
ASP - DLL
ASP - ADO
ASP Send e-mail
ASP Response
ASP Request
ASP Server
ASP Error
ASP FileSystem
ASP TextStream
ASP Drive
ASP File
ASP Folder
ASP Dictionary
ASP - vs PHP
ASP - File
ASP - Date
ASP AdRotator
ASP BrowserCap
ASP Content Linking
ASP Content Rotator
AJAX Intro
AJAX ASP
AJAX Database
ASP - Hosting SQL
ASP - Hosting MySQL
ASP - Manual
Link Exchange
Contact Us

HOME   OTHER RESOURCES    CONTACT US

Copyright 2012-13 ASPEducation.com . All rights reserved.

HTML Tutorials | Free Tips and Tricks | Banking News | Star Dose | Desi Hindi Jokes | Swamiji Online | Income Tax | Joke Site | SMS remix