ASP Cyclic Statement Summary _ Application Skills

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.