On error goto 0?

  • Thread starter Thread starter Brian Tozer
  • Start date Start date
B

Brian Tozer

Exactly what is accomplished by the line of code seen often in VBA 'On error
Goto 0'?

Thanks
Brian Tozer
 
Brian Tozer said:
Exactly what is accomplished by the line of code seen often in VBA 'On error
Goto 0'?

Exactly what is accomplished by failing to read online help for the On Error
statement other than spending several minutes to several hours waiting for
an answer that could have been gotten in a few seconds with the expenditure
of a bit of efficient effort?
 
From VBA, go to Help - F1 and do a search for "On Error Statement"
On Error Goto 0 switches off error handling.
 
If an error occurs in the excution of the code, then execution drops the the
next line after the statement.
Thereby trapping the error and allowing execution to continue. Depending on
the nature and severity of the error this may or may not be acceptable.
Cheers
N
 
Sorry my statement 'thereby trapping the error' should have read 'thereby
not trapping (ignoring) the error'
cheers
N

Nigel said:
If an error occurs in the excution of the code, then execution drops the the
next line after the statement.
Thereby trapping the error and allowing execution to continue. Depending on
the nature and severity of the error this may or may not be acceptable.
Cheers
N






----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption
=---
 
Rob,

I don't think it switches error handling off, it just disables any enabled
error handler in the current procedure. In other words, it defaults to the
inbuilt (crash and burn) error handling.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
I think the "GoTo 0" part would be confusing to those new to vba. Code use
to have line numbers, and GoTo 0 was the code used to turn error handling
off. Seems to me that "GoTo 0" does not make sense anymore. Maybe we
should send in a request for a new code to turn it off? Not sure what a
good command name would be though.

However, vba can still do line numbers, so I don't think Microsoft will be
changing it anytime soon. :>)

Sub Demo()
10 Dim A As Long
20 A = 0
30 A = 100 / A
End Sub

Glad we don't have to do that anymore! :>)
 
You are right. I actually read what I wrote after I posted and thought
about correcting myself. Having also referred to the Help file I decided not
to.
 
Back
Top