How to trap connect error? [Resolved]
Hi,
I have a problem with winsock.
If I accidentially or intentionally click on the connect button more then once, I had the following error.
Run-time error '40020';
Invalid operation at current state
Question:
How can I trap or eliminate the problem of clicking on connect more then once?
I had tried the following code and doesn't seems to work as expected. :(
VB Code:
Private Sub cmdConnect_Click()
If tcp.State = sckConnecting Then
tcp.Close
Exit Sub
End If
tcp.Connect ServerIP, Port
End Sub
Re: How to trap connect error?
Ok NVM. I found out that I should close the connection before connecting thats all... :D :bigyello:
VB Code:
Private Sub cmdConnect_Click()
tcp.Close
tcp.Connect ServerIP, chatPort
End Sub