Asp loop statements have the following categories:
The function of loop statements is to repeatedly execute program code. Loops can be divided into three categories: one type repeats the statement before the condition becomes "false", one type repeats the statement before the condition becomes "true", and the other type repeats the statement according to the specified number of times. The following loop statements can be used in VBScript:
Do...Loop: Loop when (or until) the condition is "true".
While...Wend: Loop when the condition is "true".
For...Next: Specify the number of loops and repeat the statement using a counter.
For Each...Next: For each item in the set or each element in the array, repeat a set of statements.
Now look at a few examples:
<body>do while..loop<br /><%'do while..loop Similar to while(){}i=6Do while i < 10response.Write(i&"<br>")i=i+1Loop%>do ..loop until<br /><%'do while..loop Similar to while(){}i=6Do response.Write(i&"<br>")i=i+1Loop until i < 10%>while....wend <br /><% i=10 while i<20 response.Write(i&"<br>") i=i+1 wend %>For...Next<br /><% for i=0 to 10 ' Includes 0 to 10 response.Write(i&"<br>") if i=5 then exit for end if next%>For.....each....next<br /><% dim array(3) array(1)="A" array(2)="B" array(3)="C" for each a in array response.Write(a&"<br>") next%></body></html>Read data from the database
<% while not rs.eof %> <li><a href="#"><%=rs("classname")%></a></li> <% rs.movenext wend %>The above is the summary of the asp loop statement. I hope it will be helpful for everyone to master the asp loop statement.