Do... Loop Structure

Source: Internet
Author: User
<% @ Page Language = "vb" Debug = "true" ContentType = "text/html" ResponseEncoding = "gb2312" %>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Title> do... Loop Structure </title>
<Script language = "vb" runat = "server">
Sub page_load ()
Dim counter as integer = 0
Dim number as integer = 5' you can try to replace this number with 10
Do while number> 6' enter the loop when the comparison condition is true
Number-= 1
Counter + = 1
Loop
Response. Write ("put while in front and run" & counter & "Times <br> ")
Dim cout as integer = 0
Dim num as integer = 5' you can try to replace this number with 10
Do
Num-= 1
Cout + = 1
Loop while num> 6' is placed at the end of the loop, and the loop must be inspected at the beginning.
Response. Write ("put while on the back and run" & cout & "Times <br> ")
Dim cout1 as integer = 0
Dim num1 as integer = 3' here you can change it to a number larger than 5 to run it.
Do until num1 = 5' enters the loop when the comparison condition is false
If num1 <5 then exit do 'is a number smaller than 5, you must use this judgment. Otherwise, an error occurs. do not believe it.
Num1-= 1
Cout1 + = 1
Loop
Response. Write ("using until to run" & cout1 & "Times <br> ")
Dim cout2 as integer = 0
Dim num2 as integer = 10
While num2> 5
Num2-= 1
Cout2 + = 1
End while
Response. Write ("using while to run" & cout2 & "Times <br> ")
Dim cout3 as integer = 0
Dim num3 as integer = 8
While num3 <> 10
If num3 <0 then exit while
Num3-= 1
Cout3 + = 1
End while
Response. Write ("using exit while to run" & cout3 & "Times <br> ")
End sub
</Script>
<Head>
<Body>
</Body>
</Html>

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.