Mani wrote:
From FORM2 I would like to access the richtexbox control on FORM1.
Dim m_Form1 As New Form1
Creates a new instance of the Class Form1 and store a reference to it in
the variable m_Form1.
MessageBox.Show(m_Form1.RichTextBox1.Text)
Retrieves the Text property of the Richtextbox control on that /new/
form - probably not a lot in it at this point ... ;-)
Forms are Classes, so to access a property of one, you have to have a
reference to that particular object. Pass a reference to Form1 to
Form2, as in
[Form1.vb]
Sub button_Click( ... )
Dim f2 as New Form2
f2.Master = Me
f2.ShowDialog() ' or whatever
End Sub
Class Form2
Public WriteOnly Property Master() as Form1
Set(value As Form1)
_Master = value
End Set
End Property
Private _Master As Form1 = Nothing
Sub otherButton_Click( ... )
MessageBox.Show( _Master.RichTextBox1.Text )
End Sub
End Class
HTH,
Phill W.