Amazon.com: PC Books || Educational Software || Magazines
Amazon: Books-CA || Software-CA || Books-UK || Software-UK

HTML | Javascript | ASP | PHP | VBScript | SQL | Hardware | PC FAQ| WinXP|

Learn to Build, Upgrade, or Repair your Computer Ebook + PC Safety 101 kwwebservice.com Reasonably priced web development & hosting
ASP Basics
Introduction
Variables & Arrays
Sub & Functions
If Statements
Case Statements
Loop Statements
Date Objects
Form Processing
Text File Objects
Database Access
Adding Record
Updating Record
Deleting Record
Virtual Includes
Cookies
Server Variables
Creating Login Page
E-mail
ASP Books @
CA Amazon
UK Amazon
US Amazon

  :: Home
PC Topics
  :: Build A PC
  :: Windows XP
  :: PC Help
Tutorials
  :: HTML
  :: JavaScript
  :: ASP
  :: PHP
  :: VBScript
  :: SQL
Miscellaneous
  :: Code/Scripts
  :: Forum
  :: Links
  :: Contact us
  :: Tell A Friend
  :: In Somali
  ::
Web Articles
  Top Web Hosting
Reviews
  Processing
Online Card Payment Guide
  Domain name
registration & buying guide
  Getting
a website online guide
  Search Engine
submission & optimization tips
Netfirms Web Hosting
Free trial
Quality business correspondence.
Yahoo! Search Marketing

ASP Loop Statements

Loops are set of instructions that repeat elements in specific number of times. Counter variable is used to increment or decrement with each repetition of the loop. Two major groups of loops are, For..Next and Do..Loop. While..Wend is another type of Do..Loop. For statements are best used when you want to perform a loop in specific number of times. Do and While statements are best used to perform a loop an undetermined number of times.
This is a For..Next example which counts from 1 to 5.
<%
Dim counter
counter=0
for counter = 0 to 5
   response.write("The counter is: "&counter&"<br>")
next
%>

The above example increments a variable counter from 0 to 5, values of counter are incremented by 1 on each run before 6. We can modified how the values are incremented by adding step # to the for counter statement.
Here is For..Next example incrementing values by two.
<%
Dim counter
counter=0
for counter = 0 to 5 step 2
   response.write("The counter is: "&counter&"<br>")
next
%>

The following example increments a variable counter from 5 to 0 The values are decremented by 1.  It's first example with reversed order.
<%
Dim counter
counter=0
for counter = 5 to 0 step -1
   response.write("The counter is: "&counter&"<br>")
next
%>

Do Loop

Do..Loop structure repeats a block of statements until a specified condition is met.  There are three types of Do..Loops. Do..Until, Do..While, and While..Wend.  Do..While and While..Wend performs a loop statement as long as the condition being tested is true while Do..Until performs a loop statement as long as the condition tested is false.  In both cases, you have a choice to perform the test at start of the loop or at the end of the loop  

This Do..Until loop example performs the test at the start of the loop:
<%
Dim counter
counter=5
Do
   response.write("The counter is: "&counter&"<br>")
counter=counter-1
loop until counter =0
%>
You can also accomplish the loop this way:
<%
Dim counter
counter=5
Do Until counter=0
   response.write("The counter is: "&counter&"<br>")
counter=counter-1
loop
%>

Case Statements Form Processing
Listed @ ConsumerVote.com - The Consumer Rated Web Directory
PC Articles
  Computer Safety
prevent viruses & Spyware