share controls between 2 windows

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:

If tPort.Open Then
txtData.text= “attn -D”
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,


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


Add a public property to a module, of type TextArea


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.