<html>
<%
dim shtloop as short=cshort(request("loop"))
dim shtx as short=1
do
response.write("循环执行了:" & cstr(shtx) & "次<br>")
shtx+=1
loop until shtx>shtloop
%>
</html>
do while...loop 循环
这种do while...loop 结构的循环,则是先判断条件判断式是否成立,才会跳入循环内执行。其语法如下:
do while 条件判断式
程序代码叙述
loop

do while...loop 循环在执行时,会先判断条件是否成立,再进入循环。循环内的程序叙述执行到loop 时,则表示跳回do while 叙述执行后面的条件判断式,倘若为true 成立即跳入循环继续执行;倘若为false 则跳出循环,继续程序的执行,我们来观察下列的范例:
<html>
<%
dim shtloop as short=cshort(request("loop"))
dim shtx as short=1
do while shtx<=shtloop
response.write("循环执行了:" & cstr(shtx) & "次<br>")
shtx+=1
loop
%>
</html>
外这种do while...loop 循环还有另一种写法,那就是while...end while。其语法如下所示:
while 条件判断式
程序代码叙述
end while
上述程序代码范例可以改成:
<html>
<%
dim shtloop as short=cshort(request("loop"))
dim shtx as short
| 对此文章发表了评论 |

