» Basic Looping by rdove |
|
(Login to remove green text ads)
This tutorial is going to cover simple looping with ASP. If you have ever used Visual Basic then a lot of this will look very fimilar because it is essentially the same.
First I will talk about a for...next loop. For...Next loops are good when you want to increment by numbers. For example:
Code:
Dim i
For i = 0 to 10
response.write(i)
Next
This will write out all the numbers from 0 to 10, then the loop will break.
Next is the While loop. A while loop will process until the condition returns false.
Code:
Dim i
i = 0
While i < 10
response.write(i)
i = i + 1
Wend
In this instance numbers 0 to 9 will be outputted on the page. Since i needs to be less than 10 after 9 is reached the loop will break because it has returned false.
Next we have the Do loops. There are 2 types of Do loops: Do...While & Do...Until. Do...While Loops are similar to While loops, they will process until the condition is false.
Code:
Do While i < 10
response.write(i)
i = i + 1
Loop
On the Otherhand, a Do...Until loop will process until the condition is met or true.
Code:
Do Until i = 10
response.write(i)
i = i + 1
Loop
That is a short basic tutorial on the types of loops that can be used in ASP.
Tutorial written by:
Ryan Wischmeyer 2004, Indianapolis, IN
|
|