Error Trap or Continue

I understand that this is an older programming environment, but I need to clear some code VB6, and I find that most of them use:

On Error Resume Next

What is the general opinion about use On Error Resume Next?

Of course, if there is an error, you want the application to stop what it was doing, undo any data changes and inform the user about the error, and not just resume it.

When is it recommended to use On Error Resume Next?

+5
source share
3 answers

, , . . , , , , , , , .

, , .

+5

On Error Resume Next . , , . :

On Error Resume Next
GetAttr strFilePath
If Err Then
    On Error GoTo 0
    'Deal with "no file" scenario.
Else
    On Error GoTo 0
    'Open and process the file.
End If

, . Err.Number .

, GoTo, , . VBScript , , , , GOTos .

- ... Trust the Force, Luke .

+7

- , , , , , .

+2

All Articles