Property Set/Get

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

Guest

Hi,
I have 2 forms, from1 and form2 and a class called classEntity which have a
property get/set for variable called Var1.
have how can I set Var1 to be = 2 in form1 and then get this value in form2

thanks
 
yes, but if I want to access the value of Var1 in from2 I have to create an
instance of form1 using "New" keyword and by doing that the value of Var1
from form1 will be lost.
 
You will need to pass an instance of form1 into form2 so that form2 can
access the properties of form1. No need to create a new instance of
form1.

Form2:

Private _form1 As Form1
Public Sub New(f As Form1)
_form1 = f
End Sub

Public Sub Foo()
MsgBox(_form1.Var1)
End Sub

Form1:

Public Sub Bar()
Dim f2 As New Form2(Me) '<---- Pass Form1 into form 2

f2.Foo()
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

MDI child windows' position 1
Variables in LINQ 2
How to use data on two forms 5
Shared Sub Main 10
Handling Forms 2
pass array as a function parameter 3
Variable Inside Variable 4
Question on MDIchild forms 6

Back
Top