| Answer: |
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 LBound and 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 Dim aFoo aFoo = Array("Hello, ", "World!", "How ", "are ", "you?")
Dim iItem
For Each iItem in aFoo Response.Write iItem & "<BR>" Next
|
The above code will produce the following output (when viewed through a browser):
Hello, World! How are you?
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?
Happy Programming!
|