Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become a ASP.NET Expert!

Join 244,072 ASP.NET Programmers for FREE! Get instant access to thousands of ASP.NET experts, tutorials, code snippets, and more! There are 1,336 people online right now. 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
9 Jun, 2006 - 03: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
+Quote Post


Amadeus
RE: QUERY: 'On Error Resume Next' Scope Rules
9 Jun, 2006 - 04:39 AM
Post #2

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,976



Thanked: 116 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
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 7/3/09 11:48PM

Live ASP.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

ASP.NET Tutorials

Reference Sheets

ASP.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month