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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to reference the UserControl inside same project

Status
Not open for further replies.

granni

Programmer
Nov 8, 2000
36
SG
I am doing an ActiveX, some of the code i need to put in a basic module and a class, these are all in the same project

But i cannot access the UserControl object in inside the module and class

In a normal project to get a Form in a class, i just use the Form's name, but in this ActiveX project it seems i cannot do so, can anyone help? In Christ
 
If I understand correctly you want to call your active-x from a class module. You can't do it directly, but you can use Withevents in your class. In your class you create a public event in the General declarations section e.g.

Code:
Public Event UpdateParentNecessary(ByVal Why As String)

In your active-x you create an instance of you class also in the general declarations section, with use of the Withevent statement. Lets say your class is called MyClass

Code:
Private WithEvents m_oMyClass As MyClass

Now you can click on the dropdownbox where it says "(General)" and you will see m_oMyClass in the list. Clicking it will create:

Code:
Private Sub m_oMyClass_UpdateParentNecessary(ByVal Why As String)
End Sub

In your class every time you have to do something in your active-x, you can use the:

Code:
RaiseEvent UpdateParentNecessary("message")

And you can evalute 'Why' in your active-x and respond accordingly.

Hope it helps!

Jordi Reineman
 
Thanks firstly for the help, but there is a slight problem, i am using a collection of the Class u mention, u see i bind one Class to each control on the UserControl.

Unless i can declare an array withevents, i cant go on this road In Christ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top