-
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?
-
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.
-
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
-
Use Resume Redo instead of Goto Redo
-
Thanks, that works perfectly