🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.basic.visual.misc
Article #491

Re: on error

#491
From: Glen Rafferty
Date: Mon, 09 Aug 1999 00:00
44 lines
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?
>
Technical Details
Message-ID: <37ae6ce7.46474512@thenews.celticweb.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7okfa9$loj$1@vnews.prima.com.ar>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1053fc,592429ab1549cf4b
X-Google-Attributes: gid1053fc,public
X-Google-Thread: 110e3b,592429ab1549cf4b
X-Google-Attributes: gid110e3b,public
X-Google-Thread: fb992,592429ab1549cf4b
X-Google-Attributes: gidfb992,public
From: runningwolf@celticweb.com (Glen Rafferty)
Subject: Re: on error
Date: 1999/08/09
Message-ID: <37ae6ce7.46474512@thenews.celticweb.com>
X-Deja-AN: 510496210
Content-Transfer-Encoding: 7bit
References: <7okfa9$loj$1@vnews.prima.com.ar>
Content-Type: text/plain; charset=us-ascii
Organization: Internet Maine/HarvardNet
Mime-Version: 1.0
Reply-To: runningwolf@celticweb.com
Newsgroups: comp.lang.basic.visual.misc,comp.lang.visual.basic,es.comp.lenguajes.visual-basic