Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: QUERY: 'On Error Resume Next' scope rules

Thread Tools

Re: QUERY: 'On Error Resume Next' scope rules

Kevin Spencer
Posts: n/a
Perhaps the reason you haven't seen any discussion about it here is that
although the "On Error" statement is included in VB.Net for those who have
come from a VB6 or VBScript background (I would suppose), it is not
recommended to use it. ASP and ASP.Net are entirely different technologies.
ASP is purely procedural; ASP.Net is purely object-oriented. In fact, you
are the first person I've ever heard of that has used it.

You might be surprised to learn that the "infamous" try/catch structured
exception handling is part of the .Net specification, and is supported by
VB.Net, C#, and every other .Net language (AFAIK). It is far better to use
try/catch than to use "On Error." You can find it documented here:


Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

I recycle.
I send everything back to the planet it came from.

"dhruba.bandopadhyay" <(E-Mail Removed) m>
wrote in message news:(E-Mail Removed). com...
> This has been puzzling me for very long time and no where has
> talked about the scope of a 'On Error Resume Next' statement.
> When we program ASP(.NET) pages then we usually like to let
> ASP(.NET) stop at errors and report back to us. However there
> are parts of our scripts that we know an error will be thrown
> and we encapsulate that area inbetween:
> On Error Resume Next
> Err.Clear
> 'Try block
> If Err.Number Then
> 'Catch block
> End If
> On Error GoTo 0
> This is similar to the infamous try {} catch(e) {} blocks in
> Java/C++, etc.
> If we forget the last line 'On Error GoTo 0' then our ASP(.NET)
> scripts runs over all errors thrown and we find it hard to
> find bugs. So the big question is, does 'On Error Resume Next'
> go out of scope when it's written inside a block
> (eg. Function)?
> Function Function1()
> On Error Resume Next
> 'Our code
> End Function
> When the Function1 call returns, does the outside calling scope
> automatically stays as it was (On Error GoTo 0)?
> --
> dhruba.bandopadhyay
> ------------------------------------------------------------------------
> Posted via
> ------------------------------------------------------------------------

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Scope Rules fctk C Programming 3 04-18-2006 11:03 AM
rules for Cisco PIX 525 firewall rules KAS Cisco 2 10-02-2005 07:12 PM
Scope rules C++ 3 09-15-2005 12:51 AM
Special scope rules for static operators? =?ISO-8859-1?Q?=22J=2EJ=2EGarc=EDa=22?= C++ 4 05-29-2005 05:42 PM
scope rules in nested functions Andrew Collier Python 0 01-29-2005 10:07 PM