Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple array question 1

Status
Not open for further replies.

MikeT

IS-IT--Management
Feb 1, 2001
376
US
I print the elements of my array to the screen.
The array is declared as having 100 elements, but rarely actually has that many. I want a for next loop for the actual elements in the array. I tried:

for x = 0 to len(myArray)
response.write myArray(x)
next
OR
for each item in myArray
response.write myArray(item)
next

These does not work.
How can I do this?
 
Try using the boundaries:
Code:
For i = LBound(myArray) to UBound(myArray)

Next i
 
Hi,

If the array is declared with 100 positions, you don't know how much it is used!! Even if you use the first 5 positions the others will have 0!! Thus you don't know if the 0 is a value set by you or not. What you can do is re-dimension de array as you need it so you can use all it range. Here is a link that shows how to use Redim Statement
Regards,
Luís Silva
 
I seem to remember reading somewhere that re-dimming was processor intensive and should be avoided. Usually, there are about 60-70 elements in the array, do the extra 40-30 empty elements actually warant re-dimming?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top