Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default how to redim the type of variant element

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default how to redim the type of variant element

Just change the data type to String

Dim myDyn() As String


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"lvcha.gouqizi" wrote in message
oups.com...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default how to redim the type of variant element

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default how to redim the type of variant element

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.

--
Regards,
Tom Ogivly

"lvcha.gouqizi" wrote in message
ups.com...
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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default how to redim the type of variant element

thanks, I got it there



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default how to redim the type of variant element

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))
--
HTH...

Jim Thomlinson


"lvcha.gouqizi" wrote:

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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ReDim Object array as parameter of Variant array Peter T Excel Programming 4 May 10th 05 02:11 PM
Type mismatch accessing variant array too many times peter Excel Programming 6 February 12th 05 10:07 PM
Variant type for Excel cell percentage data format Mike Excel Programming 4 October 21st 04 01:03 AM
Variant Array with String Values - Type Mismatch jamiee Excel Programming 2 March 7th 04 03:39 AM
How to check a Variant for its data type TBA[_2_] Excel Programming 5 January 9th 04 11:04 PM


All times are GMT +1. The time now is 01:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"