I have Form1(Textbox1, Button1) and Form2(Textbox2).
When I click Button1 of Form1, it will display Form2. In Form2, i want to access the Textbox1(any controls) of Form1. Any solution?
Printable View
I have Form1(Textbox1, Button1) and Form2(Textbox2).
When I click Button1 of Form1, it will display Form2. In Form2, i want to access the Textbox1(any controls) of Form1. Any solution?
Form1.Textbox1
In VB.NET all forms are classes and form instances are just objects. One thing you could do is pass a reference to the first form in the constructor of the second, so when you show it it already has knowledge of the first form.
One key principle to correct object-oriented design is scope - you shouldn't give anything a higher scope than needed.
VB Code:
Public Class Form2 Public Sub New(ByRef frm As Form2) frm.TextBox1.Text="Welcome" End Sub End Class
Thanks. Why in VB 2005 we can use FormName.AnyControl without declare an instance of form? Is it shared member or something else?
You are referring to My.FormName, which is an instance of the form