On error goto 0?

B

Brian Tozer

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

Thanks
Brian Tozer
 
H

Harlan Grove

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?
 
R

Rob van Gelder

From VBA, go to Help - F1 and do a search for "On Error Statement"
On Error Goto 0 switches off error handling.
 
B

Bob Phillips

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)
 
D

Dana DeLouis

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! :>)
 
R

Rob van Gelder

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.
 
Top