how to redim the type of variant element

  • Thread starter Thread starter lvcha.gouqizi
  • Start date Start date
L

lvcha.gouqizi

Hi there,

I define a dynamic array as
Dim myDyn() as Variant

Is there any way to redim its element type as String?

The reason that I need to do this is because when I pass myDyn(1) to a
function whose parameter is String, it reports "ByRef argument type
mismatch". I am wondering if this is the reason.

Any other suggestion to avoid this bug report?

Thank,
lvcha
 
But how about this is a two dimension array of mixed data types?

My myDyn is like this

myDyn(1, index) are String, and
myDyn(2, index) are Date
 
If the original Variant type is necessary (which it usually is not) and you
can not change it to string then you can use the CStr() function to change
the variable type just as you pass the argument...Something like...

Ucase(cstr(myDyn(1))
 
Just do an explicit conversion in the call to the function or change the
function to expect a variant. I provided you a detailed answer in response
to your first posting of this question.
 
Back
Top