What does the “On Error Resume Next” statement do?

后端 未结 7 2566
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-29 07:54

I came to some VBScript examples, and I saw the statement On Error Resume Next basically at the beginning of the script.

What does it do?

7条回答
  •  执念已碎
    2020-11-29 08:41

    It's worth noting that even when On Error Resume Next is in effect, the Err object is still populated when an error occurs, so you can still do C-style error handling.

    On Error Resume Next
    
    DangerousOperationThatCouldCauseErrors
    
    If Err Then
        WScript.StdErr.WriteLine "error " & Err.Number
        WScript.Quit 1
    End If
    
    On Error GoTo 0
    

提交回复
热议问题