Calling procedure

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I know that I can call a procedure of Form1 from Form2 ?
But I don't know how, because I am a beginner.
Can anybody tell me please ?

Thanks in advance.
 
Thanks for your reply Armin,

But I want is just simple.

I have a procedure in Form1, let's say : CountingNet()
I want to call this procedure from Form2.
So, what I have to do ?
I have tried with (in Form1) :
-Public sub CountingNet()
-Shared sub CountingNet()
-etx..
And in Form2 : Imports MyProject.Form1

But it didn't work.

Please tell me how to code it in VB.Net !

Thanks.
Joachim.
 
Joachim said:
Thanks for your reply Armin,

But I want is just simple.

I have a procedure in Form1, let's say : CountingNet()
I want to call this procedure from Form2.
So, what I have to do ?
I have tried with (in Form1) :
-Public sub CountingNet()
-Shared sub CountingNet()
-etx..
And in Form2 : Imports MyProject.Form1

But it didn't work.

Please tell me how to code it in VB.Net !

There are several ways depending on the situation. One is:

Form2:
private m_Form1 as form1
public sub new(byval Form1 as Form1)
myclass.new
m_form1 = form1
end sub

I assume you are creating Form2 within Form1:
In Form1:
dim f as form2
f = new form2(me)
f.show

Within Form2, you can now access Form1:
m_form1.CountingNet


In general, I prefer not to access a form in order to make the other class
(Form2) more abstract, so it can be also used in other situations.

--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
I do not create Form2 from Form1.
Actually Form1 is MDIParent and the Form2 is MDIChild.
So, I want to call a procedure that belong to Parent form from Child.

Joachim.
 
Hi Armin,

Thanks A lot.
This is what I need.
Now my program works correctly.

Regards,
Joachim.
 
Back
Top