<script language= "VBScript" runat= "Server" >
Sub Chkfirstuntil () ' Pre-loop check
Dim count,x
Count=0
X=0
Do until x<10 ' do...loop statement, executed when X<10
Count=count+1
X=x+1
Loop ' do...loop statement end flag
Response.Write ("<center>") ' shows the middle of the text
' The text displayed
Response.Write ("Do until...loop execution Result: Program execution <font color=red>" &count)
Response.Write ("</font> times <br><br>") ' <br> means line wrapping
End Sub
Sub Chklastuntil () ' After loop check
Dim count,x ' Declare variable
Count=0 ' initialization variable
X=0 ' initialization variable
Do ' do...loop statements
Count=count+1 ' Count value plus 1
X=x+1 ' x value plus 1
Loop until x<10
Response.Write ("<center>") ' text is displayed in the middle
' The text to display
Response.Write ("Do...loop Until execution results: Program execution <font color= red>" &count)
Response.Write ("</font> times <br><br>")
End Sub
</script>
<title>do Loop Statement Instance example21</title>
<body>
<%
Chkfirstuntil
Chklastuntil
%>
</body>
While statement instance
<%
function Checkletter (str) ' STR is the string to be detected
Checkletter=true ' initialization
letters= "ABCDEFGHIJKLMNOPQRSTUVWXYZ" initialization
For I=1 to Len (str) ' Len function to return string length
' Mid (str,i,1) returns the string str i character, the UCase function converts the character to uppercase
Checkchar=ucase (Mid (str,i,1))
if (InStr (Letters,checkchar) <=0) Then ' Checkchar does not exist in letters
Checkletter=false
Exit function ' jumps out of the Function procedure
End If
Next ' End for loop
End Function
%>
<title>while Wend Instance example22</title>
<body>
<form method= "POST" action= "example22.asp" name = form1>
<p align= "center" > Please input string: <input type= "Text" Name= "string" size= "Value=<%=request.form" ("string")% >></p>
<p align= "center" ><input type= "Submit" value= "confirm" name= "Submit" ></p>
</form>
<%
If Request.Form ("submit") = "OK" then
Str=request.form ("string") reads the input string
letters= "ABCDEFGHIJKLMNOPQRSTUVWXYZ" initialization
Length=len (str) ' length of the string entered
I=1 ' initialization variable
While I<length+1 ' while loop
' Mid (str,i,1) returns the string str i character, the UCase function converts the character to uppercase
Checkchar = UCase (Mid (str,i,1))
if (InStr (Letters,checkchar) <=0) Then ' Checkchar does not exist in letters
' Give a hint
Response.Write ("<script>alert (non-letter in string entered) </script>")
Response.End ' End of ASP file execution
End If
I=i+1
Wend ' End While loop
End If
%>
</body>