Loop Statements in ASP.NET
Loop Statements are used to execute and repeat a block of statements depending on the value of a condition. There are three types of Loop Control Statements in ASP.NET:
1. For Loop: These loop requires a start number and an end one. It increments the value of its counter automatically.
Dim Counter as Integer For Counter = 1 To 3 Response.Write("The value of loop Counter is " & Counter & "<br>"
2. While Loop: These loop will execute as long as the condition give is true. It does not increment the value of its counter automatically.
<% Dim j as integer = 1 While (j<=50) response.Write(i) response.Write("SRK") response.Write("<BR>") j= j+ 1 end while %>
3. For Each Loop: If you work with a collection or an array, then for each loop is very useful.
Dim Dog As String Dim Cats(1) As String Cats(0) = “Tom” Cats(1) = “Jerry” For Each Dog In Cats Response.Write(Dog & "<be>")