If Winsock1.State <> sckConnected Then
Winsock1.Connect
End If
I have the above code inside a function it runs fairly good, but ones in a while it gives me the following error at the if statement.
Error 400020, Invalid operation at current state.
So because of the error at the if statement it won’t connect. How can I fix this problem? Why does it happen once in while, rather than every time I check the state? A solution I thought was trying to connect inside the error catch without checking the state. Will it cause more problems or an infinite state?
Here’s what I am thinking:
On error goto ErrorWinsock1
'……. More code here
If Winsock1.State <> sckConnected Then
Winsock1.Connect
End If
'…… more code follows
ErrorWinsock1:
Select case Err.number
Case 40020:
Winsock1.Connect
Resume Next
Case Else
End Select
Winsock1.Connect
End If
I have the above code inside a function it runs fairly good, but ones in a while it gives me the following error at the if statement.
Error 400020, Invalid operation at current state.
So because of the error at the if statement it won’t connect. How can I fix this problem? Why does it happen once in while, rather than every time I check the state? A solution I thought was trying to connect inside the error catch without checking the state. Will it cause more problems or an infinite state?
Here’s what I am thinking:
On error goto ErrorWinsock1
'……. More code here
If Winsock1.State <> sckConnected Then
Winsock1.Connect
End If
'…… more code follows
ErrorWinsock1:
Select case Err.number
Case 40020:
Winsock1.Connect
Resume Next
Case Else
End Select