share controls between 2 windows

Hello,
i have two windows on my project.
On the main window i have added the serial port control and a text area to R/W to the port.
Now i am trying to use the other window as a quickpad to send qiuck command to the teaxt area on the main window.
my question is how can i make the connection between the buttons on the 2nd window and port control and text area on the 1st window?
this is the code i added to the pressed action on the first button:

“tPort.XmitWait
If tPort.Open Then
txtData.text= “attn -D”
tPort.Write(txtData.text)
Else
MsgBox(“The serial port could not be opened.”)
End If”

but ofcourse i get an error that tPort and txtData does not exist.

Thank you,

Shay.

Make both your controls public. Then you can say in Window1

window2.mycontrol.dosomething

Or:
Add a public property to a module, of type TextArea

eg

TheTextArea as TextArea

When your window opens, set that variable = the actual control

eg TheTextArea = self.txtTheActualControl

then you can ‘talk’ to that control from anywhere

TheTextArea.text = "Something"

But you ought to test for nil before using it.