ASP do while and while statement instances

Source: Internet
Author: User

<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&LT;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>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.