I was wondering if anyone can help me. I got two forms I can send data from one form to the other one when I press the SEND button. I’m trying to get data from one form to the other when I press the ‘GET’ button, to get an idea what I’m trying to do have a look at this image:
Hopefully it will make it more clear what I’m trying to do. Also before anything is done you have to press the ‘CONNECT’ button, to link to the forms first.
Here the code I used so far:
Private Sub Form_Load() tcpServer.LocalPort = 1001 tcpServer.Listen frmClient.Show End Sub Private Sub tcpServer_ConnectionRequest(ByVal requestID As Long) If tcpServer.State <> sckClosed Then tcpServer.Close tcpServer.Accept requestID End Sub 'Listens for data from form 1 and displays it Private Sub tcpServer_DataArrival(ByVal bytestotal As Long) Dim strData As String tcpServer.GetData strData txtInput.Text = strData End Sub Private Sub timer1_timer() Label1.Caption = tcpServer.State If tcpServer.State = 0 Then tcpServer.Listen End Sub
Private Sub Form_Load() tcpClient.RemoteHost = "localhost" tcpClient.RemotePort = 1001 End Sub 'Connect Form 2 to Form 1 Private Sub cmdConnect_Click() tcpClient.Connect End Sub 'Sends data from form 1 to Form 1 Private Sub Command1_Click() tcpClient.SendData txtOutput.Text End Sub Private Sub timer1_timer() Label1.Caption = tcpClient.State End Sub
Any help will much appreciated