Re Dim

VisualBasic keyword, short for ReDimension. Used to resize an already allocated array. Can be combined with the Preserve keyword to transfer the contents of the current array into the newly sized array.

In VisualBasic, an array is actually a ComAutomation SafeArray.

What do you mean by that?

VB does not have a native array type. So... given the definition of a SafeArray, even if you had an array within the scope of a method, that array would not be stack based. This is an obvious performance hit.


But VB (or is it just VBA) supports either an array of variants, or a variant which is an array. What frosted me (I seem to recall) was that you could grow and shrink arrays down to zero, but were unable to declare an empty array to start.

I believe this problem exists in VbScript as well. You can type a variable, which is just a Variant, as an array only by allocating it. Otherwise you can leave it empty (VT_EMPTY) and later assign it to an array via the Array(...) keyword or via a return value from some property/method. In order to use the ReDim functionality however, the variable must already contain an array.


CategoryVisualBasic


EditText of this page (last edited March 10, 2003) or FindPage with title or text search