SiteMap  | About    

for loop

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.
  For var=[startValue] To [endValue] [Step]

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 .

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.



<html xmlns="">
<head runat="server">
	<title>Untitled Page</title>
	<form id="form1" runat="server">
		<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
		<br />
		<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

Click the following links to see full source code

C# Source Code
VB.NET Source Code
default.aspx.vb (C) 2018    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.