Form Variables

  • Thread starter Thread starter sympatico
  • Start date Start date
S

sympatico

I have a form (form1). I made a dialog box for it called (Dialog1). Form1
has 2 initialized classes. I need to be able to modify the value of a
variable in form1 from form2 when the OK button is clicked. I know how to do
this in visual basic 6 (which i no longer use very much because .NET is much
better).

Thanks
 
Is Form2 created as an object in Form1? If you are, then just add a
reference of form1 to form2 when you create it.

Public class Form2
dim F1 as Form
sub new(byref Form1Ref as Form)
F1 = form1ref
end sub
sub SomeFunction
F1.SomeProperty = Me.Something
end sub
end class

public class form1
sub SomeFunction()
dim F2 as new form2(Me)
end sub
end class

Hope it helps
Chris
 
Well, if you make each of your variables a public property of your form
you could set and get them easily.

So in form2 you would do something like
form1.MyValue = 1
 

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

Back
Top