<script>ec(2);</script> 在do while循环的另一种常用后... Next循环的循环。在do while循环语句重复语句 块的次数不定。重复的陈述或者当条件为真或直到条件变为True。语法如下所示: Do [While|Until] condition statements Loop Do statements Loop [While|Until] condition 在这方面,这个循环内的代码将执行至少一次的情况。在有一个例子: 下面的例子定义了一个循环,开始与i = 0。循环将继续运行,因为我只要小于或等于 10。我将增加1每次循环运行。 Select ActionSelect AllTry It<% Dim i 'use i as a counter i = 0 'assign a value to i Do While i<=10 'Output the values from 0 to 10 response.write(i & "<br >") i = i 1 'increment the value of i for next time loop executes Loop %> 现在,让我们考虑一个更有用的例子,创建下拉几天,几个月或几年清单。您可以使 用此登记表的代码,例如。 <% 'creates an array Dim month_array(11) month_array(0) = "January" month_array(1) = "February" month_array(2) = "March" month_array(3) = "April" month_array(4) = "May" month_array(5) = "June" month_array(6) = "July" month_array(7) = "August" month_array(8) = "September" month_array(9) = "October" month_array(10) = "November" month_array(11) = "December" Dim i 'use i as a counter response.write("<select name=""day"">" & vbCrLf) i = 1 Do While i <= 31 response.write("<option value=" & i & ">" & i & "</option>" & vbCrLf) i = i 1 Loop response.write("</select>") response.write("<select name=""month"">" & vbCrLf) i = 0 Do While i <= 11 response.write("<option value=" & i & ">" & month_array(i) & "</option>" & vbCrLf) i = i 1 Loop response.write("</select>") response.write("<select name=""year"">") i = 1900 Do Until i = 2005 response.write("<option value=" & i & ">" & i & "</option>" & vbCrLf) i = i 1 Loop response.write("</select>") %>
|