Hi,
I've got a UserControl component and a form in my project. I'd like to call functions defined in my UserControl from my form... but vb can't find the UserControl.
How could I do ?
Subs, functions & properties that are declared as 'public' is available as methods and properties of you usercontrol.
1) open a new exe project
2) add a new (file menu) usercontrol project.
3) add a public sub to the usercontrol and close the usercontrol design window.
4) drop an instance of you usercontrol to you exe form and test that ".YourPublicSub" is a method of your usercontrol (which be default is named usercontrol11).
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
Th problem is that I don't want to create a new exe project but an activeX control project... so dropping an instance of my usercontrol on my form seems to be impossible.
What can be done is :
Set myUserControl = CreateObject "myProjectName.UserControlName"
and then call :
Call myUserControl.myFunction(parameters)
... but I don't think it is actually a nice solution. Moreover, it seems to create a new instance of my usercontrol object, so I can't access to the existing objects of the main usercontrol object (did you follow me ?)
Why do you have a form in your ActiveX .ocx project - is the form instantiated by the UserControl? If so, why not pass a 'Me' type object reference from the User Control to the form just after you instantiate it?
ie...inside your usercontrol..
Dim oFrm as MyForm
set oFrm = new MyForm
oFrm.Display(Me)
and inside your form "MyForm"...
private moParentControl as MyUserControlName
public sub Display(byval oParent as MyUserControlName)
set moParentControl = oParent
me.show vbModal
end sub
I like this last answer.
Thanks a lot.
But unfortunaly, I don't know how to do it : the type "MyUserControlName" is not known in my form (I don't know why). So :
private moParentControl as MyUserControlName
is ineficient.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.