Thread View: comp.lang.basic.visual.misc
2 messages
2 total messages
Started by Zeff
Sun, 08 Aug 1999 00:00
on error
Author: Zeff
Date: Sun, 08 Aug 1999 00:00
Date: Sun, 08 Aug 1999 00:00
2 lines
742 bytes
742 bytes
I'd like to know how to use the "on error" command, when somebody wants to open a file and that file doesn't exist. Which is that code of error?
Re: on error
Author: Glen Rafferty
Date: Mon, 09 Aug 1999 00:00
Date: Mon, 09 Aug 1999 00:00
44 lines
1778 bytes
1778 bytes
Example:
Private Sub Command1_Click()
' Handle File Not Found error
On Error GoTo FileErr
....<your code here>
Exit Sub
FileErr:
If Err.Number = 53 Then
MsgBox "Error " & Err.Number & " " & Err.Description, vbCritical, "Error"
Exit Sub
End Sub
Error 53 is the "File Not Found" error. You can also write that to handle pretty much any
error and report it to you. An example would be:
Private Sub Command1_Click()
' Handle File Not Found error
On Error GoTo FileErr
....<your code here>
Exit Sub
FileErr:
MsgBox "Error " & Err.Number & " " & Err.Description, vbCritical, "Error"
Exit Sub
End Sub
That will handle pretty much any error in that sub only. It isn't global. Try it and let
me know if it was useful to you.
Glen
On Sun, 8 Aug 1999 20:37:27 -0300, "Zeff" <dzeff@intramed.net.ar> wrote:
>I'd like to know how to use the "on error" command, when somebody wants to
>open a file and that file doesn't exist. Which is that code of error?
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads