Re: UDT Array Parameter
From: Joel Whitehouse (joelwhitehouse_at_gmail.com)
Date: 12/21/04
- Next message: Mike D Sutton: "Re: True Type Font"
- Previous message: Mike D Sutton: "Re: True Type Font"
- In reply to: Jim Mack: "Re: UDT Array Parameter"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 21 Dec 2004 19:23:15 GMT
> The message tells the story. Move the Type definition into a standard
> module and make it Public.
I had already followed your advice at the time that I posted.
I realized what the problem was;
It looks like the array passing was already working - it appears that my
test function was *not* the late-bound function that the error message
was talking about.
Even though my Type declaration is public in a module, I still got the
same error message; apparently, the late-bound function is the IsArray()
function, which takes a variant and determines if it can be used as an
array.
However, since my function header already used an array that didn't need
to be tested, my call to IsArray() involved casting a UDT as a variant,
hence, the error message.
'Here's the code I used:
'-----------------------------------------------------
Private Sub Form_Load()
Dim test() As myTestType, b As Boolean
ReDim test(0 To 7)
b = TestFunc(test, 1)
End Sub
Private Function TestFunc(ItemArray() As myTestType,_
ByVal ItemElement As Long) As Boolean
If Not IsArray(ItemArray) Then 'Uneccesary and invalid Call!!!!!!!!!
Err.Raise 13, , "Type Mismatch"
TestFunc = True
Exit Function
End If
MsgBox ItemArray(ItemElement).ThisNum
MsgBox ItemArray(ItemElement).ThatNum
TestFunc = True
End Function
'Module Code
Public Type myTestType
ThisNum As Integer
ThatNum As Integer
End Type
Lesson learned: When testing new coding techniques, "keep it simple,
stupid."
Thanks guys!
-Joel Whitehouse
- Next message: Mike D Sutton: "Re: True Type Font"
- Previous message: Mike D Sutton: "Re: True Type Font"
- In reply to: Jim Mack: "Re: UDT Array Parameter"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|