||First of all, it is possible to get the upper and lower bounds of an array by using the |
UBound and the
LBound functions (For more information on
UBound, be sure to read the FAQ: How can I determine the upper or lower bounds of an array?), but sometimes it is faster and easier to extract the array information without these.
The following snippet of code displays each element of the array
aFoo using a
For Each...Next loop.
'Create the aFoo array
aFoo = Array("Hello, ", "World!", "How ", "are ", "you?")
For Each iItem in aFoo
Response.Write iItem & "<BR>"
The above code will produce the following output (when viewed through a browser):
This example may seem a little confusing at first, but all it does is loop through each element that is in the array. If there are no more elements in the array, the loop will end.
Added by Scott Mitchell
You can also snarf the contents out of an array using a
For ... Next loop (which is mentioned, but not discussed, at the beginning of this FAQ). Furthermore, if you want all of the array's contents in a single string, you can use the
join function. For example using both of these techniques, be sure to check out: How can I display all of the contents of a single-dimension array?