The most common technique for iterating the contents of an array is to use a For
Next loop and indicate the subscript for the array within the loop, like this:
<%
Dim strArray(3)
strArray(0) = "Paul"
strArray(1) = "John"
strArray(2) = "George"
strArray(3) = "Ringo"
Dim intCount
For intCount = LBound(strArray) To UBound(strArray)
Response.Write strArray(intCount) & "<br>"
Next
%>
But another approach is to use a For Each loop. This technique doesn't require
you to keep track on the subscript for each item, nor does it require you to
interrogate the LBound and UBound on the array. This approach is shown below:
<%
Dim strArray(3)
strArray(0) = "Paul"
strArray(1) = "John"
strArray(2) = "George"
strArray(3) = "Ringo"
Dim strItem
For Each strItem in strArray
Response.Write strItem & "<br>"
Next
%>
Iterate Arrays with For Each
By ElementK Journals, published on 18 Jul 2001
| Filed in
You might also like...
ASP (3.0) forum discussion
-
Invitation to take part in an academic research study
by researchlab (0 replies)
-
How to insert & edit unique value using store procedure
by umeshdaiya (0 replies)
-
How to troubleshoot Epson laser printer?
by daisywyatt618 (0 replies)
-
view state is stored after the page post-back
by shriniwas.khatri852 (0 replies)
-
Transfer selected rows from one GridView to another GridView in aspxform(ASP.NET)
by dorsa (0 replies)
ASP (3.0) podcasts
-
Hanselminutes: Startup Series: Buying an Existing Small Company or Online Application
Published 8 years ago, running time 0h34m
Scott talks to Rob Walling about how he purchases small niche products and companies online and revitalizes them. He recently purchased an existing product that consisted of a 300 gig database and tens of thousands of lines of Classic ASP. How did he know it was valuable? What's next?
Comments