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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arrays

Status
Not open for further replies.

motte

Programmer
May 31, 2001
155
US
Hi all,

Not really new to asp, but I'm a rookie on this topic as it pertains to asp. Do arrays always have to be defined with a dimension? Is it possible to create an array of undetermined size? Or would you have to create an array of, let's say, 10, and redimension it if someone only chooses 3 things?

I have no example of this or any hypotheical situation; I just want to know what kind of possibilities there are with arrays. Any code snippets would be very helpful too.

Mike
 
well, there are two things i would do:

1.)
Code:
Dim ary(0)
Dim i

For i = 1 to ItemCount '//Itemcount is the "unknown" amount of stuff i want to array
  ReDim Preserve ary(i)
  ary(i) = Item(i)
Next

2.)
Code:
Dim ary

ary = Array("one", "two", "three",...,"fifty")

Hope it helps. _________________
Bixarrio

e = m * (c ^ 2)
 
Bixarrio,

A few questions:
1. In part 1's assignment line,
ary(i) = Item(i)
is Item, as you refer to it, supposed to be ItemCount that you called it at the top of the loop?

2. Why do you need part 2 if part 1 adds the new element thru the loop?...or are 1 & 2 seperate cases?

Mike
 
Ok all, I'll take a look. Thanks for your advice.

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top