C
Craig Remillard
I have a string array, declared by:
Dim HRColHdrs(3) As Variant
I explicitly define the strings, then pass them to a function, as "ColHdrs" shown below.
Private Sub HdrChk(ByVal ShtName As String, ByRef ColHdrs As Variant)
Dim i, n As Long
Debug.Print (Len(ColHdrs))
End Sub
Within this function, I would like to determine how many elements are in this array that was passed. However, when I use the len() function, I get Type mismatch error.
Things I have tried:
-Declaring "HRColHdrs" as an array of type String in the main function (no change in error)
-Declaring the "ColHdrs" as a variable of type String or Object rather than Variant
-Declaring "ColHdrs" as a ByVal variable
-Using the ColHdrs.Length method (error changes to "Object required")
-I used debug.print to make sure that I can read the individual elements of ColHdrs in the subroutine - I can.
Oh, if only every language handled arrays like Matlab scripting :-/.
The only workaround I can think of is to step through a For loop and address each element of the array directly, until it throws a subscript error, then use the error handler to extract from the loop.
EggHeadCafe - Software Developer Portal of Choice
ASP.NET 2.0: Using the Menu Control
http://www.eggheadcafe.com/tutorial...b210-d64f9d7293b6/aspnet-20-using-the-me.aspx
Dim HRColHdrs(3) As Variant
I explicitly define the strings, then pass them to a function, as "ColHdrs" shown below.
Private Sub HdrChk(ByVal ShtName As String, ByRef ColHdrs As Variant)
Dim i, n As Long
Debug.Print (Len(ColHdrs))
End Sub
Within this function, I would like to determine how many elements are in this array that was passed. However, when I use the len() function, I get Type mismatch error.
Things I have tried:
-Declaring "HRColHdrs" as an array of type String in the main function (no change in error)
-Declaring the "ColHdrs" as a variable of type String or Object rather than Variant
-Declaring "ColHdrs" as a ByVal variable
-Using the ColHdrs.Length method (error changes to "Object required")
-I used debug.print to make sure that I can read the individual elements of ColHdrs in the subroutine - I can.
Oh, if only every language handled arrays like Matlab scripting :-/.
The only workaround I can think of is to step through a For loop and address each element of the array directly, until it throws a subscript error, then use the error handler to extract from the loop.
EggHeadCafe - Software Developer Portal of Choice
ASP.NET 2.0: Using the Menu Control
http://www.eggheadcafe.com/tutorial...b210-d64f9d7293b6/aspnet-20-using-the-me.aspx