Here's the way I do it....
In form2: Add a form-level variable and change the constructor for form2:
Private ff As Form
#Region " Windows Form Designer generated code "
Public Sub New(ByVal fx As Form)
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
ff = fx
'Add any initialization after the InitializeComponent() call
............... ETC.
Then in the Load method of form2 you can do something like this:
Dim f As Form1
f = CType(ff, Form1)
TextBox1.Text = f.TextBox1.Text
......................
The above can be further simplified of you KNOW that you will ONLY be
instatiating this form from form1:
Private ff As form1
#Region " Windows Form Designer generated code "
Public Sub New(ByVal fx as Form1)
.....
ff=fx
.... etc.
Then in Load:
Textbox1.text=ff.Textbox1.Text
HTH,
Larry Woods
"JAPSTER" <wh*******@hotmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
An application has a startup form (Form1). A second form (frm2),
created from within Form1. Each form has a textbox.
To access the text in TextBox1 in frm2 from Form1, you use:
frm2.TextBox1.Text = "XXXXXX"
How do I refer to the TextBox1 controls Text property in Form1 from
frm2?
Form1.TextBox1.Text doesn't work and generates a designtime error:
Reference to a non-shared member requires an object reference.