Click to See Complete Forum and Search --> : To All CODE GURUS: How to access a subroutine or function from another form


M G Vinod Kumar
March 13th, 1999, 01:30 AM
Hi,

I have a usercontrol and a form in project. I want to access some functions or subroutines of UserControl from the Form.

I can do the reverse. ie. call a form's method from a usercontrol. example: Form1.Method.



BUT THIS DOESN'T WORK IN A FORM. Example: UserControl.Method.


Please help me, since I need to do some action based on some events occured in the form.

Any ideas would be of great help.


Thanks,


Vinod

Vinayak Sapre
March 13th, 1999, 09:31 PM
If your methods are public you should be able to access the methods. I am assuming you are calling a method of an instance of user control.


Dim myctl as MyUserControl

Set myctl = new MyUserControl

myctl.Method


should work...


You can't call

MyUserControl.Method

for two reasons,


1) VB does't support class methods.

2) Unlike forms, VB won't create global instance of your user control.

In case of forms it creates hidden global object of the form class.