For Loops statement, which allows code to be repeatedly executed. In ASP.NET programming sometimes you have to faces situation to repeat a task for several times or you have to repeat a task till you reach a condition, in these situations you can use loop statements to achieve your desired results.
In VB.NET the FOR NEXT Loop , execute the loop body (the source code within For ..Next code block) to a fixed number of times.
vb.netFor var=[startValue] To [endValue] [Step] [loopBody]Next [var]
var : The counter for the loop to repeat the steps. starValue : The starting value assign to counter variable . endValue : When the counter variable reach end value the Loop will stop .C#loopBody : The source code between loop body
for(initialization; condition; step)statement
initialization : Initialize the value of variable. condition : Evaluate the conditionstep : Step taken for each execution of loop body
The following ASP.NET example declare two variables startVal and maxVal and then assign the values 1 and 10 respectively and display the number 1 to 10 using for loop.
Default.aspx
Untitled Page
Click the following links to see full source code
C# Source Code
VB.NET Source Code
ASP.NET Statements - Related Contents
Advertisement
ASP.NET Related Topics