Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    asp
  » Basic Looping
      by rdove
 Page 1 of 1 
   

(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




 
 Page 1 of 1 
   

Rate This Article
1 2 3 4 5 6 7 8 9 10





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle