Array() vs thing()?

  • Thread starter Maury Markowitz
  • Start date
M

Maury Markowitz

Can someone explain the difference between the Array(...) syntax and the
thing() as string syntax?

I wrote a bunch of subs using the thing() as String API, but it turns out
that the underlying COM object requires Array's. I thought these were the
same thing, but no I see they are not, and I have to re-write them all
(darn). But I'd like to be sure I understand them first!

Also, if I have a Dim MyArray(10) As Integer and want to turn that into an
Array, is there an easy way to do this? If so, I could convert in a single
sub and save re-writing a lot of code "here and there".

Maury
 
G

George Nicholson

afaik:

Dim thing() as string ' = a string array
Dim MyArray(10) as integer '= a fixed integer array

Dim thing() '= a variant array

Per VBA Help the Array() function returns a Variant array. It may simply be
that the COM expects a Variant type, so its possible that the only code you
need to change is replace "as String" with "as Variant" (that's all a
rewrite using Array() would do...).

HTH,
 
Top