After another common use of do while loops ... The loop of the next loop. Repeat a statement in a Do While loop statement
The number of blocks is uncertain. Repeated statements or when the condition is true or until the condition becomes true. The syntax looks like this:
do [while| Until] Condition
Statements
Loop
Todo
Statements
Loop [while| Until] Condition
In this case, the code within the loop will execute at least once. In one example:
The following example defines a loop, which begins with i = 0. The loop will continue to run as long as I am less than or equal to
10. I'm going to add 1 each time the loop runs.
Select Actionselect alltry it<%
Dim i ' use I as a counter
i = 0 ' Assign a value to I
Do While i<=10 ' Output of the values from 0 to 10
Response.Write (I & "<br >")
i = i + 1 ' increment the value of I for next time loop executes
Loop
%>
Now, let's consider a more useful example of creating a drop-down list for days, months or years. You can make
Use the code for this registration form, for example.
<%
' 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 (Ten) = "November"
Month_array (one) = "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>")
%>