Total Pageviews

Saturday, October 27, 2018

SCOPE OF ON ERROR... STATEMENT

















The effect of ON ERROR ... ends as soon as one of the following is encountered:
  1. Another ON ERROR .... (Maybe in the form of ON ERROR RESUME x or ON ERROR GOTO x)
  2. Exit Sub / Exit Function within the same sub/function where defined.
  3. End Sub / End Function of the sub/function where defined.
IS IT BAD TO USE ON ERROR RESUME NEXT?
Yes and No.
Don't use without knowing what the effect of this statement would be. Avoid if possible. Keep the scope short wherever not possible.
To nullify the effect of an ON ERROR RESUME NEXT statement, you can call ON ERROR GOTO 0

No comments: