Private Sub Telnet1_State()
On Error GoTo OnError ' use intrinsic error handling
' State of the Telnet1 connection has changed...put up user feedback
Select Case Telnet1.State
Case tcpConnecting
Label1.Caption = "Client Connecting..."
Case tcpConnected
Label2.Caption = "Client Connected to " & Tcp1.RemoteAddress
Case tcpClosing
Label3.Caption = "Client Closing..."
Case tcpClosed
Label4.Caption = "Client Closed"
End Select
Exit Sub
OnError: ' Any error jumps here
Debug.Print "Error #" + CStr(Err.Number) + ": " + Err.Description
End Sub