Is there a smart workaround to add extra elements to a multidim array? I’m trying to wrap my head around this but sofar no success. The array is a class property and not created with a DIM statement.
Apparently, Redim does the job.
What about .Append ?
Append doesn’t work on a multidim array.
An easier way is to make an array of a class
Make a class myClass that has all the properties you want to store in the multi-dim array.
Dim myArray() as myClass
Then you can happily append, insert etc additional items.
[quote=399945:@Markus Winter]An easier way is to make an array of a class
Make a class myClass that has all the properties you want to store in the multi-dim array.
Dim myArray() as myClass
Then you can happily append, insert etc additional items.[/quote]
Could you give an example?
Lets say you have a multi-dim array where you save data on the cars you have
Column1 is model (eg Audi), column2 is color (eg silver), column3 is km driven (eg 12467) etc
Make a class car with properties
Model as string
Color as string // you could also do this as color
km as string // you could also do this as double
Add an array myCars() as car
Dim myCar as car
MyCar.Model = Ford
MyCar.Color = blue
MyCar.km = 54863
MyCars.append myCar
Now you can not only easily add/delete/insert etc further cars to the array, but you can also easily add more properties to the class car without breaking anything.
Aah! I understand. That’s a nice approach. Thanks Marcus!