Sorry I missed abit out of my original post..
The usercontrol I am working on is Active X, so it wont be sitting on a form.
Any Ideas
Thanks
AH
Main Topics
Browse All TopicsHi there
Sorry, i have pretty much no experience in VB so can someone tell me how I can call a method of a usercontrol from a module.
Thanks
AH
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
So where will it be sitting? A UserControl by definition is an activeX control, there isn't any other sort. In order to function it has to be sited within a container that supports such controls, examples of these are a form, a picture box, Internet Explorer pages such as html, asp etc and also other applications may allow activeX controls to be sited on them. So your control must be sited somewhere, the key then to solving this particular problem is to determine where your control is sited.
Unless I suppose you have instantiated the control in code which is a special case as this involves instantiating the classes exposed by the control rather than the UI that is normally associated with it. In this case you would simply reference the method directly.
MyUserControl.MyMethod
Where you have declared MyUserControl like this:
Dim MyUserControl As Object
Set MyUserControl = CreateObject("MyUC.MyUCtl"
MyUserControl.MyMethod "Test"
Or
Dim MyUserControl As MyUC.MyUCtl
Set MyUserControl = New MyUC.MyUCtl
MyUserControl.MyMethd "Test"
I need to use the control in Visual Foxpro - its a Tapi control as VFP isnt the best tool for working with API calls
I have a module in Visual Basic that contains all of my API declares and a function that is used by an API call to send messages back into VB
From this module I need to trigger an event on the control so that when I use it in VFP I can place foxpro code in there.
Correct me if im wrong - module events cannot be accessed when the control is used in Foxpro, Internet explorer etc.
Thanks
Addition:
In the module,the property Let/Get should be like this:
Public m_lObj As Long
Public Property Let theCtrl(ByVal nCtrl As cCtrl)
m_lObj = ObjPtr(nCtrl)
End Property
Public Property Get theCtrl() As cCtrl
Dim ct As cCtrl
If (m_lObj <> 0) Then
CopyMemory ct, m_lObj, 4
Set theCtrl = ct
CopyMemory ct, 0&, 4
End If
End Property
Business Accounts
Answer for Membership
by: TimCotteePosted on 2002-09-18 at 05:09:07ID: 7287955
FormName.UserControlName.M ethodName
As you are in a module, you need to use the formname first, so for example to call the "MyMethod" method of usercontrol "UC1" sited in form "MyForm1" you would use:
MyForm1.UC1.MyMethod
With any required / or optional parameters as usual.
If you want to always refer to the current form then you can use:
ActiveForm.UC1.MyMethod
Assuming of course that the appropriate usercontrol is sited on this current form.