ASP for each statement instance

Source: Internet
Author: User


<title>for Each statement instance example27</title>
<body>
<form method= "POST" action= "example27.asp" name = form1>
<p align= "center" > Please input e-mail: <input type= "text" name= "email" size= "value=<%=request.form" ("email")%> ></p>
<p align= "center" ><input type= "Submit" value= "confirm" name= "Submit" ></p>
</form>
<%
If Request.Form ("submit") = "OK" then
Email=request.form ("email") ' Read the input string
Names=split (email, "@") ' The Split function is to split the string into multiple substrings with the specified characters and save the substrings in a one-dimensional array
If UBound (names) <>1 Then ' UBound function returns the maximum subscript of an array
Response.Write (' <script>alert (' bad message format! ') </script> ') ' gives hints
Response.End ' End Run ASP program
End If
For each name in names ' for Each loop statement
The If Len (name) <=0 Then ' len function gets the length of the string
Response.Write (' <script>alert (' Message format Error! ') </script> ") ' string length is less than or equal to 0, give a hint
Exit for ' Jump out for loop
End If
Next
End If
%>
</body>


Look at an application example

If Upload.form ("uptype") = "Up" then "if upload picture
I=1 ' I don't think you're going to be able to accumulator me underneath I'll always be 1
For every formname in Upload.file ' list all uploaded files are you sure Upload.file is an array? No, it's definitely an error.
Set File=upload.file (FormName)
If Trim (file.filename) <> "" Then
Filetype=upload.form (FormName)
Upload.savetofile Formname,server.mappath (Formpath&file.filename)

Url= "url" ' "&i&"
RS (URL) =file.filename
I=i+1
End If ' You are missing this end if
Next ' (This is 48 lines) that you didn't comment out ...
Else
RS ("Url1") =uoload.form ("Url1")
RS ("Url2") =uoload.form ("Url2")
RS ("Url3") =uoload.form ("Url3")
End If
' The code is not all I can see so much you try it

ASP for all in Next loop statement
ASP script Loop statement for each...in ... Next

The function of a circular statement is to repeat the execution of the program code, which is used to run the statement block for a specified number of times, using a counter variable in the loop, with the value of the variable increasing or decreasing with each cycle of the For...next statement. For each...in ... Next is not to run the statement the specified number of times, but to repeat a set of statements for each element in the array or for each item in the collection of objects. This is useful when you do not know the number of elements in the collection. Its syntax is as follows:


For each element in group
[Statements]
[Exit For]
[Statements]
Next [element]

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.