ReDim

ceaser

Active Member
Licensed User
Hi

I can remember from my VB days the function "ReDim". If you had an array with say 10 values you would specify DIM A(9). If you now received more values in this array, say another 6, then you could use the function ReDim A(15) without losing any of your old data.

This would become handy in my "CAD" program. As the user adds more entities to a drawing one could have a subroutine to increase the "DIM" to suit the number of entities in the drawing.

Or is there a way of which I am not aware?

Thanks
Michael
 

ceaser

Active Member
Licensed User
Hi mjcoon

Thanks for the reply, but I fail to see how that can help me. Is it possible for an example please?

Thanks
Michael
 

mjcoon

Well-Known Member
Licensed User
Thanks for the reply, but I fail to see how that can help me. Is it possible for an example please?

No, I can't write an example because there are so many ways of approaching it. The simplest would be to use an ArrayList for holding the data but perhaps that would be too much of a re-write and/or a hit on performance.

I had in mind that using
AddArray(array As Array()) : Adds the contents of array to the end of the items (if any) already in the ArrayList.​

and
ToArray() : Returns an array containing copies of all the elements of the ArrayList.

you can use the extensibility of ArrayList just when you want to expand your array but put the data back into a plain array. But the decisions depend on how you use your arrays and where the overheads are best kept.

Mike.
 
Top