I have 2 form called form1 and form2
why i cannot use this code
form1.textbox.Text = "Hello"
????
Jump to PostBecause it cannot refer to itself through its default instance name , for this you have to use
Me
try this:
Me.Textbox1.Text="Hello"
Jump to Postyour current form refers to as
Me
.
so , if you coding behindForm2
then you have to useMe.Textbox1.Text
instead ofForm2.Textbox1.Text
.but if you are working on
Form1
and you wanna access textbox exist onForm2
then you have to use
Form2.Textbox1.Text
Because it cannot refer to itself through its default instance name , for this you have to use Me
try this:
Me.Textbox1.Text="Hello"
If i was on form2 ?
form2.textbox1.Text
?
your current form refers to as Me
.
so , if you coding behind Form2
then you have to useMe.Textbox1.Text
instead of Form2.Textbox1.Text
.
but if you are working on Form1
and you wanna access textbox exist on Form2
then you have to use
Form2.Textbox1.Text
i work on form1
form2.textbox.Text
it coming out an error :
Reference to a non-shared member requires an object reference.
You have to refer to a particular instance of an object. Use
form2.TextBox1.Text
rather then
form2.TextBox.Text
dim NewForm as new form2
NewForm.TextBox1.Text = "My Text"
NewForm.Show
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.