Results 1 to 2 of 2

Thread: How to trap connect error? [Resolved]

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    12

    Resolved 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:
    1. Private Sub cmdConnect_Click()
    2.     If tcp.State = sckConnecting Then
    3.         tcp.Close
    4.         Exit Sub
    5.     End If
    6.     tcp.Connect ServerIP, Port
    7. End Sub
    Last edited by igmeou; Apr 28th, 2005 at 06:14 AM.
    Will the laziest programmers produced you the easliest way to code?

  2. #2

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    12

    Re: How to trap connect error?

    Ok NVM. I found out that I should close the connection before connecting thats all...

    VB Code:
    1. Private Sub cmdConnect_Click()
    2.     tcp.Close
    3.     tcp.Connect ServerIP, chatPort
    4. End Sub
    Will the laziest programmers produced you the easliest way to code?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width