Cosmos75
Registered User.
- Local time
- , 19:39
- Joined
- Apr 22, 2002
- Messages
- 1,281
I have the following code.
But I would like to be able to have a DebugPrintArray() function that can handle an array of any data type. I've looked around and I think that you can only pass arrays of the exact same data type.
Does anyone know of a way around this?
Related Links
ACC2000: How to Pass an Array as an Argument to a Procedure
Type Mismatch: Array or User Defined Type Expected
Code:
[B]Sub [COLOR="Blue"]CreateArray[/COLOR]()[/B]
Dim lngArray(1 To 10) As Long
Dim i As Long
For i = LBound(lngArray) To UBound(lngArray)
lngArray(i) = i
Next i
DebugPrintArray lngArray()
[B]End Sub[/B]
[B]Sub [COLOR="blue"]DebugPrintArray[/COLOR](AnArray() As Long)[/B]
Dim i As Long
For i = LBound(AnArray) To UBound(AnArray)
Debug.Print "AnArray (" & i & ") = " & AnArray(i)
Next i
[B]End Sub[/B]
Code:
[COLOR="Green"]'This will not work.[/COLOR]
[B]Sub [COLOR="blue"]DebugPrintArray[/COLOR](AnArray() As [COLOR="Red"]Variant[/COLOR])[/B]
....
Related Links
ACC2000: How to Pass an Array as an Argument to a Procedure
Type Mismatch: Array or User Defined Type Expected
Last edited: