If the goal of the exercise is to transfer a text value from one textbox on Form1 to a textbox on Form2, then there is no need to go through a shared public variable. Here's how to do it:
The Main BAS module loads and shows the forms. Focus is on Form1:
Public Sub Main()
Form1.Show
Form2.Show
Form1.SetFocus
End Sub
The Text1_Change event for Form1 contains:
Private Sub Text1_Change()
Form2.Text1.Text = Me.Text1.Text
End Sub
As soon as you start typing the text in the textbox on form1, it will appear on form2.
HOWEVER, This might not work in the next version of VB called VB.NET.
Some preliminary information for that version shows that direct referencing of a control on another form will fail. See: "10 Ways to prepare for VB.NET" VB Prog Journal, December 2000, pp62-65.
So, What's the alternative? Yes, you can still used shared public variables. But as said before (thread222-37333 and thread222-42216) this is NOT the way to go. Use public Properties where you can. Here's how: (code for the Main BAS module is not changed)
Add following code to Form1:
Private m_strTextValue As String
Public Property Get TextValue() As String
TextValue = m_strTextValue
End Property
Private Sub Text1_Change()
m_strTextValue = Me.Text1.Text
End Sub
As soon as you start entering the text, the internal variable m_strTextValue will be updated. This value can not be changed from the outside (as it is private).
If one likes to fetch that value he/she has to do it through the Property TextValue.
For instance, Form2 might do so upon activation:
(add this code to Form2)
Private Sub Form_Activate()
Me.Text1.Text = Form1.TextValue
End Sub
You'll observe that as soon as you click Form2, the text will (magically) appear.
This presumably will still work in VB.VET