I am using a COM object in VB6. The COM object has a function Foo(Long, Long, Rect). Rect is a struct defined in the COM object implementation. My VB6 code (a button on a form) is like below:
Private Sub btnTestCom_Click()
Set ComObj = CreateObject("ObjectName")
Dim rect As DISPLAY_RECT
rect.Left = 20
rect.Top = 20
ComObj.Foo(101, 0, rect) ' Error here
End Sub
At the last line it is giving me this compilation error: "Only user-defined types defined in public object modules can be coerced to or from a variant or passed to late-bound functions".
Other COM functions that do not have user-defined type parameters are working fine.
How do I solve this problem?
Thanks.