do…loop 结构

<%@ 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 结构</title>
<script language="vb" runat="server">
sub page_load()
dim counter as integer=0
dim number as integer=5 '可以尝试把这个数换成10
do while number>6 '当对比条件为true就进入循环
 number-=1
 counter+=1
loop
response.Write("把while放在 前 面运行了"& counter & "次<br>")
dim cout as integer=0
dim num as integer=5 '可以尝试把这个数换成10
do
 num-=1
 cout+=1
loop while num>6 '放在后面就是循环一开始就要进行一次再做检察
response.Write("把while放在 后 面运行了"& cout & "次<br>")
dim cout1 as integer=0
dim num1 as integer=3 '这里可以先换成大于5的数字运行看
do until num1=5 '当对比条件为false就进入循环
if num1<5 then exit do '如果是小于5的数字,就一定要用这个判断,否则就会出错,不信试下。
 num1-=1
 cout1+=1
loop
response.Write("使用until运行了"& cout1 & "次<br>")
dim cout2 as integer=0
dim num2 as integer=10
while num2>5
 num2-=1
 cout2+=1
end while
response.Write("使用while运行了"& cout2 & "次<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("使用exit while运行了"& cout3 & "次<br>")
end sub
</script>
<head>
<body>
</body>
</html>
原文地址:https://www.cnblogs.com/thcjp/p/334945.html