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.net
For var=[startValue] To [endValue] [Step] [loopBody]
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)
initialization : Initialize the value of variable. condition : Evaluate the condition
step : 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.
Click the following links to see full source code