ASP's circular statements have the following categories:
The function of a circular statement is to repeat the execution of the program code, which can be divided into three categories: a class repeats the statement before the condition becomes "false", a class repeats the statement before the condition becomes "true," and another class repeats the statement at a specified number of times. The following looping statements can be used in VBScript:
Do ... Loop: loops when (or until) the condition is true.
While ... Wend: Loops When the condition is true.
For ..... Next: Specify the number of loops and repeat the statement using the counter.
For Each ... Next: Repeats a set of statements for each item in the collection or for each element in the array.
Now let's look at a few examples:
<body> do
while....loop<br/>
<%
' do while....loop similar to while () {} i=6 does in. NET
While I < ten
response. Write (i& "<br>")
i=i+1
loop
%> do ...
loop until<br/>
<%
' do While....loop is similar to the while () {}
i=6 do
response in. Net. Write (i& "<br>")
i=i+1
Loop until I < ten
%>
while....wend
<br/> <%
i=10 while
i<20
response. Write (i& "<br>")
i=i+1
wend
%> for
... Next<br/>
<% for
i=0 to ten includes 0 to
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>
Reading data from a database
<% While not
rs.eof
%>
<li><a href= "#" ><%=rs ("classname")%></a></li >
<%
rs.movenext
wend
%>
The above is the ASP Circular statement Summary, I hope to master the ASP circular statements help.