20
Case 8: LblState.Caption = "Peer closing"
Case Else: LblState.Caption = "Error"
End
Select
'set the caption of the "Connect" button
If WinSock.State = 0 Then
CmdConnect.Caption = "Connect"
Else
CmdConnect.Caption = "Disconnect"
End
If
'enable or disable the "Send" button
If WinSock.State = 7 Then
CmdSend.Enabled = True
Else
CmdSend.Enabled = False
End
If
End Sub
•
Add the code below to the
Click
event of the
CmdConnect
button. This code selects open the
connection when it is closed and to close the connection when it is not closed:
Private Sub CmdConnect_Click()
If WinSock.State = 0 Then
WinSock.Connect
Else
WinSock.Close
End
If
End Sub