Click to See Complete Forum and Search --> : how to increase dimension of n array


rao
April 17th, 2001, 05:03 PM
how to increase dimension of an array by a set number of variable?
for example i have an array

dim co(n) as double

where n is a user defined number.
and every time i do certain operation on
array co(n), i want that its dimension sould increase by same "n" number.

softweng
April 17th, 2001, 05:31 PM
Use The ReDim Statement:

Dim TestArray() as Double
Dim ArraySize as integer

'Variable to Determine The Size Of The Array
ArraySize = 10

'Dimension The Array to A Variable Value
Redim Preserve TestArray(ArraySize)




The Preserve keyword saves all data already in the array. If you don't want to save the data
dimesion the array as follows:

Redim TestArray(ArraySize)




Hope This Helps

forty7
April 17th, 2001, 05:44 PM
Looks like a great suggestion. Only thing I would change is use 2 variables for maintaining size. One could be Arraysize and the other ArrayIncrease. Then you could do:

ArraySize = ArraySize + ArrayIncrease
Redim Preserve TestArray(ArraySize)



each time you need to get a little bigger.

thanx/good luck,
adam