Error Checking does nothing

L

lorenmcguire

I have put the following code in my vbscript to catch errors, but it does
absolutely nothing. This is straight out of the book.... did I miss
something here?

Thanks

Dim strMessage
If Err.Number <> 0 Then
MsgBox "Well, That didn't Work"
strMessage = "The following error " & Err.Description & _
" has occurred in the " & Err.Source & " appliction. " & _
"The error number was " & Err.Number & ". " & _
"Please report this error to the help desk."

MsgBox strMessage,16,"Run-time Error #" & Err.Number

Exit Sub
End If
 
E

Eric Legault [MVP - Outlook]

Can you please provide some context? Your code is fine, except that if there
is no error, code after the "If Err.Number <> 0 Then" line won't run. So if
there are no errors, everything is fine!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top