Results 1 to 5 of 5

Thread: Err handle only occurs once

  1. #1
    Guest

    Talking

    The problem is that in the formload part of my program, it sets the winsock control to a certain port and then runs the .listen event. But if that port is already used it get the 'Address in use' error. I made an error handling thing that if it gets that error itll use an input box and ask them for a new port, then goto the beginning of the form load again. But if they get the address in use error again, vb takes over and gives its own error, bypassing my error handle. Any ideas on how to fix this?

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    GOTO???

    I checked this out and the way I reproduced the error was using a goto statement.
    The way I got around it was using a function to do all the work, and on the error I
    called the function instead of using a goto statement.

    If you were not using a goto, post some code and maybe I can help.


  3. #3
    Guest
    Heres the code i'm using:

    Private Sub Form_Load()
    Dim tmpPort&
    tmpPort& = 80

    Redo:
    On Error GoTo FixPort
    WebServer(0).Close
    WebServer(0).LocalPort = tmpPort&
    WebServer(0).Listen
    Exit Sub

    FixPort:
    tmpPort& = Val(InputBox("Port " & tmpPort& & " is unavailable, please enter an alternate one.", "Invalid Port"))
    GoTo Redo
    End Sub

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Use Resume Redo instead of Goto Redo
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Guest
    Thanks, that works perfectly

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