Casper's faq is excellent for a foundation on how to handle errors. He doesn't mention On error goto 0, though, since it isn't considered good practice.
Simply put, on error goto 0 disables any error HANDLERS (negates any other on error statements in your code), whereas on error resume next disables any error HANDLING (continues running as if errors didn't happen).
On error resume next is often misused to get the runtime environment to ignore errors returned by an object, that don't seem to cause trouble to the application. Trouble with that is that 5 years down the line someone notices that their accounts are several million dollars off, or whatever, the code is undocumented, and the person who wrote it is now a beet gardener in Idaho.
Use On error resume next for "inline error handling." In a situation where you know that a particular code line can cause an error, such as attempting to open a file provided by the user, you can evaluate Err.Number and see if the line made an error. (The Err object is always set, whether you've set on error resume next or not. Err.Number will be 0 if there hasn't been an error.)
Code:
Public Function GetOurFile() as Boolean
dim fn as String
On Error Resume Next
fn = InputBox "Enter File:"
'fso is an open FileSystemObject--omitting code
[COLOR=blue]fso.GetFile fn 'could raise an error[/color]
select case Err.Number
Case 0
GetOurFile = True
Case 2
MsgBox "File Not Found."
GetOurFile = False
Case Else
'reraise the error if you don't handle it
End Select
Here's a bit of code that demonstrates a couple of other features of the error handler.
Code:
Public Sub Recip()
dim x as double
On Error GoTo ErrHandler
[COLOR=red]Input:[/color]
[COLOR=blue]x = InputBox("Enter a number:") 'could cause type mismatch error
msgbox "The Reciprocal of " & x & " is " & 1/x 'could cause division by zero error[/color]
Exit Sub
ErrHandler:
Select case err.number
Case 11 'Division by zero
Msgbox "enter a number other than Zero"
[COLOR=red]Resume Input[/color]
Case 13 'type Mismatch
MsgBox "Enter a valid number"
Resume
case else
Err.Raise Err.Number
End Select
End Sub
So, here, the InputBox line will raise a type mismatch error if the user inputs something that can't be evaluated as a double, so resume will send to that line. However, if the user inputs a zero, the line after the InputBox line will raise the error, and we still want to resume at the Inputbox line. That's where you can use the place marker in the Resume statement.
HTH
Bob