SQL PHP HTML ASP JavaScript articles and free scripts to download

ASP Do While Wend commands syntax

Looping is a common requirement in any scripting language, we will learn here how to use Do While, Until, Loops to manage execution of the code blocks more than once.

Let us start with do While Loop, here the condition is checked for the starting of the loop and the code is executed only if the condition is TRUE. Here is the syntax

Do While Condition
Script block here
Loop

As long as the condition is satisfied ( or True ) the script block will be executed. Always at the starting the Condition is checked. Here is a simple script using Do While loop.

Dim my_num
my_num=1
Do While my_num <=10
Response.Write my_num & "<br>"
my_num = my_num +1
Loop

The above code will print 1 to 10 and it will fail to print 11 as the condition checking will return False. We can modify the Do While loop and keep the condition checking at the end of the Loop.

Do Script block here
Loop While Condition

Now let us change our old example and try this way.

Dim my_num
my_num=11

Do
Response.Write my_num & "<br>"
my_num = my_num +1
Loop While my_num <=10

Here we can see there is a output of 11 as the inside the loop code is executed once even before the condition is checked and found False. So this way at least once the code inside the Loop will be executed. Test the above code by adding the While condition at the starting of the loop.

Sometime we may try to execute the loop till the condition becomes True. For this we can use Do Until Loop statement. Here is the code.

Dim my_num
my_num=1
Do Until my_num > 10
Response.Write my_num & "<br>"
my_num = my_num +1
Loop

There While Wend statement for looping also. This is same as Do While Loop.
Google+

Further readings
File Included using relative and virtual in ASP
If Else & ElseIF conditional program structure control in ASP
Matching options by using Select Case statement in ASP
Do While Wend Loops in ASP
For Next Loop in ASP
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



Join Our Email List
Email:  
For Email Newsletters you can trust
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer