Connecting Tech Pros Worldwide Forums | Help | Site Map

How to Exit Sub on Error?

deko
Guest
 
Posts: n/a
#1: Nov 12 '05
Is there a shorthand way to Exit Sub On Error?

This does not seem to work:

On Error Exit Sub

And I don't want to use: On Error GoTo 0

Must I use: GoTo Exit_Here?




Steve Jorgensen
Guest
 
Posts: n/a
#2: Nov 12 '05

re: How to Exit Sub on Error?


On Fri, 16 Jan 2004 00:34:25 GMT, "deko" <dje422@hotmail.com> wrote:
[color=blue]
>Is there a shorthand way to Exit Sub On Error?
>
>This does not seem to work:
>
>On Error Exit Sub
>
>And I don't want to use: On Error GoTo 0
>
>Must I use: GoTo Exit_Here?
>
>[/color]

Yup. That's not so bad, though, is it?
fredg@example.invalid
Guest
 
Posts: n/a
#3: Nov 12 '05

re: How to Exit Sub on Error?


On Fri, 16 Jan 2004 00:34:25 GMT, "deko" <dje422@hotmail.com> wrote:
[color=blue]
>Is there a shorthand way to Exit Sub On Error?
>
>This does not seem to work:
>
>On Error Exit Sub
>
>And I don't want to use: On Error GoTo 0
>
>Must I use: GoTo Exit_Here?
>
>[/color]
Sub Something()
On Error GoTo Err_Handler
' Do your stuff here
Exit_This_Sub:
Exit Sub
Err_Handler:
Resume Exit_This_Sub
End Sub
--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.
deko
Guest
 
Posts: n/a
#4: Nov 12 '05

re: How to Exit Sub on Error?


no.... was just curious if there was a better way...

thanks for the reply

"Steve Jorgensen" <nospam@nospam.nospam> wrote in message
news:usce00tumbkqbgpk8did27nib8o8k1ekdb@4ax.com...[color=blue]
> On Fri, 16 Jan 2004 00:34:25 GMT, "deko" <dje422@hotmail.com> wrote:
>[color=green]
> >Is there a shorthand way to Exit Sub On Error?
> >
> >This does not seem to work:
> >
> >On Error Exit Sub
> >
> >And I don't want to use: On Error GoTo 0
> >
> >Must I use: GoTo Exit_Here?
> >
> >[/color]
>
> Yup. That's not so bad, though, is it?[/color]


xzzy
Guest
 
Posts: n/a
#5: Nov 12 '05

re: How to Exit Sub on Error?


try something like:

Function F_VAL_MyScreen(MyForm As Form) As Boolean
On Error GoTo F_VAL_MyScreen_Err:
F_VAL_MyScreen = False

blah, blah, blah

F_VAL_MyScreen = True
F_VAL_MyScreen_EXIT:
Exit Function

F_VAL_MyScreen_Err:
If Err.Number <> 0 Then
Call F_WL("E", -1, Err, MyForm.Name, "F_VAL_MyScreen", "", "", "",
"", Err.Number & " - " & Err.Description)
Resume F_VAL_MyScreen_EXIT:
Else
GoTo F_VAL_MyScreen_EXIT:
End If

End Function

John Bickmore
www.BicycleCam.com
www.Feed-Zone.com

"deko" <dje422@hotmail.com> wrote in message
news:lkGNb.11466$mh1.9805@newssvr27.news.prodigy.c om...[color=blue]
> Is there a shorthand way to Exit Sub On Error?
>
> This does not seem to work:
>
> On Error Exit Sub
>
> And I don't want to use: On Error GoTo 0
>
> Must I use: GoTo Exit_Here?
>
>
>[/color]


Closed Thread