ASP script loop statement

Source: Internet
Author: User
Author: scholar
In the previous two articles, we learned the variables, functions, procedures, and condition statements of the script language VBScript. This article will continue to introduce the circular statements of VBScipt, summarize the application of scripting language in ASP.
If someone tells you that learning ASP does not require any programming knowledge, then he is wrong. If I tell you that learning ASP requires a programming language, then I am wrong. The characteristic of ASP Dynamic Server Page environment is that it is written in one or more scripting languages. The scripting language can be seen as a simplified version of the programming language, which is easy to learn and understand, this provides great convenience for the designers of dynamic websites. It can be said that the proper use of the script language is directly related to the advantages and disadvantages of ASP applications. After learning the functions and condition statements of the script language VBScript in the previous article, let's continue to look at the cyclic statements in VBScript.
Loop statements are used to execute program code repeatedly. Loops can be divided into three types: one is to execute statements repeatedly before the condition changes to false, and the other is to execute statements repeatedly before the condition changes to true, the other type repeats the statement according to the specified number of times. The following statements can be used in VBScript:
Do... Loop: Loop when the (or until) condition is "true.
While... Wend: loop when the condition is "true.
For... Next: specify the number of cycles and use the counter to run the statement repeatedly.
For Each... Next: executes a set of statements repeatedly For Each element in the set or array.
Let's take a look at Do... Loop, which is a block of statements that can be run multiple times. When the condition is "true" or before the condition changes to "true", the statement block is repeatedly executed. See the following example: <Title> DoLoop. asp </title> <body bgcolor = "# FFFFFF"> <P> fill in the sales settlement records for each month from this year to this month on this page. <P>
<%
Counter = 1
Thismonth = month (now ())
Do while counter <thismonth + 1
Response. write "" & counter & "month :"
Response. write "______________________________" & "<BR> <br>"
If counter> 13 then
Exit do
End if
Counter = counter + 1
Loop
%>
<Hr> </body> This ASP program uses the cyclic statement to create a sales settlement record table, and cut and paste the above code into the workbook and save it as DoLoop. asp, and browse through HTTP in the browser. You will see the following results based on the current month.

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.