Welcome to Dream.In.Code
Getting Help is Easy!

Join 107,710 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,108 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



QUERY: 'On Error Resume Next' scope rules

 
Reply to this topicStart new topic

QUERY: 'On Error Resume Next' scope rules

dhruba.bandopad
post 9 Jun, 2006 - 04:24 AM
Post #1


New D.I.C Head

*
Joined: 30 Mar, 2006
Posts: 24


My Contributions


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)?
User is offlineProfile CardPM

Go to the top of the page


Amadeus
post 9 Jun, 2006 - 05:39 AM
Post #2


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 11,745



Thanked 17 times

Dream Kudos: 25
My Contributions


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...
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 8/30/08 03:16AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month