1 Replies - 6565 Views - Last Post: 09 June 2006 - 05:39 AM Rate Topic: -----

#1 dhruba.bandopad  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 30-March 06

QUERY: 'On Error Resume Next' scope rules

Posted 09 June 2006 - 04:24 AM

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)?

Is This A Good Question/Topic? 0
  • +

Replies To: QUERY: 'On Error Resume Next' scope rules

#2 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

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

Posted 09 June 2006 - 05:39 AM

Although I don't use vb.net all that often, the On Error Resume Next used inside a block limits it's scope to that block, IIRC, just as a try catch block would...there are some vb.net gurus here...one of them may be better qualified to comment...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1