Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error returning control from ActiveX dll

Status
Not open for further replies.

btt423

Programmer
Jan 28, 2002
31
US
I have an activex dll with a function that needs to return a TXTextControl object.

I can get it returned if I set the return type on the function to Object. However if I set the return type to TXTextControl (which is what I would think the type should be), I receive the compile error listed below. Here is the function, the line that calls the function, and the error:

Code:
Public Function GenerateTestDocument(strTestCode As String) As TXTextControl
    BuildDocument strTestCode
    Set GenerateTestDocument = frmTxc.txc
End Function

Set frmTestTxc.txc = pe.GenerateTestDocument(txtTestCode.Text)

Compile error:
Private object modules cannot be used in public object modules as parameters or return types for public procedures, as public data members, or as fields of public user defined types

What am I missing?
 
The problem is that the form on which the control is sited has private scope within the DLL. What happens if you do something like this?

'In the class module
Private txc As TXTextControl

Public Sub GenerateTestDocument(strTestCode As String)
BuildDocument strTestCode
Set txc = frmTxc.txc
End Sub

Public Property Get TXControl As TXTextControl
Set TXControl = txc
End Property

Paul Bent
Northwind IT Systems
 
Thanks for the reply.

I tried your suggestion and still received the same error.

Any other ideas?
 
I thought you might because it's only doing the same thing in a roundabout way. If you can return it successfully by typing it as Object or Variant then I guess that's what you'll have to do.

Paul Bent
Northwind IT Systems
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top