Hello and welcome to the Webmasters Forums!. This is the best place to get webmasters resources for free. Get $2 for free today, read more - Make your payment today. Download premium and professional templates for free. Get free web hosting without ads, read more. You can get lot more by simply join with this forum. To gain full access to the forums you must sign up for a free account.


Post Reply  Post Thread 

If....Then...Else - An ASP Tutorial

Post Bank
Posting Manager
******

Posts: 995
Group: Forum Team
Joined: Sep 2006
Status: Online
Make money from now. You can make money just for posting on this forum. Every discussions on this community gives you more money. $2 minimum payout. So get your payment today, SignIn with this forum.

Signin to Remove this Post

robinson
Newbie


Posts: 18
Group: Registered
Joined: Sep 2006
Status: Offline
Reputation: 0
Points: 0 (Donate)
Post: #1

If....Then...Else - An ASP Tutorial


The If....Then...Else instructions sequence is very similar to the one we may find in different kind of scripting languages. Let's check an example.

Code:
<%
AA="water"

If AA="water" Then
response.write ("I want to drink water")
Else
response.write ("I want to drink milk")

End If
%>


We may use it this way:

Code:
<%  AA="water"
If AA="water" Then %>

       I want to drink water

<% Else %>

       I want to drink milk

<% End If %>


In both cases we have checked a condition (AA="water"), and we have get a positive instruction (to write the sentence "I want to drink water"). We are allowed to execute any kind of instructions (including If....then....Else) and as many instructions as we want .


For....Next

This instructions is also similar in different programming languages. Let's see a typical example.

example.asp

Code:
I want to say "Hello" 10 times<BR>
<% For mynumber = 1 to 10 %>
<% =mynumber %> Hello<BR>
<% Next %>
END


In this case we have defined a variable ("mynumber") and using the For...Next instruction we have repeated 10 times line 4. Similarly to If....Then....Else instruction, we are allowed to execute any kind of instructions and as many of them as we want .

The For...Next instruction allows to define the value of the increment.

Code:
<% For mynumber = 1 to 20 STEP 2
response.write("Hello<BR>")
Next %>
<% For mynumber = 20 to 1 STEP -2
response.write("Hello<BR>")
Next %>


In both cases we will get the same response ("Hello" 10 times). The increment may be positive or negative as shown in the example.

23-09-2006 01:16 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites
Rate This Thread:

Forum Jump:

Sign In to Remove Ads

Download 1000's of web templates. Unlimited access!
World's Best Web Hosting
Website of the Month

Create-a-Page for Free
SOTM June 2008


Accepting Submissions
for July 2008
Resources

Recommended Sites:



Visit our Sponsors!

Current time: 08-10-2008, 01:10 AM


Copyright © 2002-2008 MyBB Group
Powered By MyBB