3

I have the following array which I want to erase, or at least clear:

Dim arrFiles() As Variant

The array has two columns, lngIndex and objFile.

I remember reading somewhere that erase only works in certain conditions. Will erase work on this type? Also, what's the best way to get the amount of memory used by an array?

Thanks

Alex P
  • 12,249
  • 5
  • 51
  • 70

1 Answers1

1

Dim arrFiles() As Variant indicates a dynamic array as it's not declared with dimensions so Erase will free the memory its using, E.g. attempting to retrieve its dimensions will error.

As for size, your array is of Variant so each number is 16 bytes and each string is 22 bytes + lenB(theString)

If you are concerned about size, don't use Variants; to mix strong types in an array structure use an array of a User Defined Type which would allow typeArray(i).Index / .File

Alex K.
  • 171,639
  • 30
  • 264
  • 288