However, you should be careful to use this statement only during the debug process or in cases where you know a particular error might occur, but there’s no harm in ignoring it. Consider the following code:
Function PrintFile
On Error Resume Next
‘....Printing code that may fail
PrintFile = Err.Number
End Sub
As you can see, this is an instance where the statement is programmatically necessary, since you don’t want the page to terminate just because it couldn’t print. If you’re debugging and you simply want to ignore an error that’s occurring in a specific piece of code, place On Error Resume Next at the start of the offending code and On Error GoTo 0 at the end, like so:
On Error Resume Next
‘ ....Some code that may fail
On Error GoTo 0
‘....More code.
In this case, the VBScript will ignore any errors that occur between the two sets of statements, but after the statements, it will trigger exceptions as usual. Except in cases where it’s programmatically necessary, you should remove all On Error Resume Next statements from your application prior to installation.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.