Is there any easy way to make array one size:) biger? without using loop or redim?
Printable View
Is there any easy way to make array one size:) biger? without using loop or redim?
you can use variant datatype...
Dim vntTest As Variant
vntTest(0) = 1
vntTest(1) = "test"
The variant datatype cannot be used as you described. If you want to resize an array, it must be declared as a dynamic array. Then it can be appropriately redimensioned.
Dim MyDynamicArray() 'Variant datatype is the default
ReDim MyDynamicArray(10)
If the Option Base is set to 0, the default, the array items will be numbered 0 to 9. If later in your code you want to add values but do not want to lose the contents of the array you can use the Preserve keyword ...
ReDim Preserve MyDynamicArray(15)
Sky,
what do you mean by "I can't use the Variant method"? I am using it right now and I have no problem with it. Your way would work too but before you issue a redim statement, you need to save your existing data to a temporary array because it will destroy everythings you have in that array...