How can i call a sub from a parent form ?
Printable View
How can i call a sub from a parent form ?
what do you mean by parent form?:confused: you mean the MDI form stuff?
I have a main form that starts another form, and in this new form i would like to call a sub from the main form .
aah, I havent worked with delegates.
You can pass the sub in the main for as a delegate to the second form and then call it from the second form.
You could also pass the main form to the second form, which isnt a very good thing to do
Pass a reference of the main form to the second form by modifying sub new in the second form:-
'second form
'declare a private variable as whatever main form is called
Private _MainForm as form1
Public Sub New(Mainform as form1)
_MainForm = MainForm
MyBase.New()
End Sub
'main form
'pass the reference to the main form
dim SecondForm as new form2(me)
SecondForm.Show()
Now in the second form you can call any public method :-
_MainForm.DoSomething
You can have as many versions of the New procedure as you want as long as they have different signitures (like any method) so you could have New procedures that accept any object you need to pass to it.
hi
i have some thing similar to this but i have a public sub in all my forms how do i call from mdi....
calling sub of mdi child from the parent mdi..
in vb6 we do me.activeform.assign (assign is the public sub)
in vb.net....?