DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2006

    QUERY: 'On Error Resume Next' scope rules

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

  2. #2
    Join Date
    Dec 2003
    The documentation for the On Error Statement should describe the behavior.
    Microsoft MVP (Visual Basic)

Similar Threads

  1. SQL2000 remote SQL query
    By lightningtechie in forum Database
    Replies: 1
    Last Post: 02-07-2006, 08:34 AM
  2. Multi-table Select Query using Joins
    By knightsg in forum Database
    Replies: 0
    Last Post: 02-16-2005, 08:07 AM
  3. Query causes fatal error with MSAccess97 db
    By Bernie in forum VB Classic
    Replies: 0
    Last Post: 12-17-2002, 07:31 AM
  4. reg...select count distinct....query
    By Mohan Ekambaram in forum Database
    Replies: 0
    Last Post: 12-09-2001, 11:56 AM
  5. reg....count distinct query
    By Mohan Ekambaram in forum Database
    Replies: 0
    Last Post: 12-08-2001, 11:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.