VbScript類型的新手,並試圖實現錯誤處理。我的方法是將錯誤對象傳遞給HandleErr子,但錯誤顯然被「On Error Resume Next」語句和子對象清除。使用Windows 7.VbScript錯誤對象通過On Error Statement清除
On Error Resume Next
Dim x
x = 1/0
msgbox "Original Error: " & err.Number & " - " & err.Description
if err.number <> 0 then HandleErr err
Sub HandleErr(objErr)
on error resume next '### Without this On Error statement, the script runs fine.
msgbox "Error in HandleErr: " & objErr.Number & " - " & objErr.Description '### objErr.Number becomes zero.
WScript.Quit objErr.Number
End Sub
我想有一個簡單的答案。任何幫助將不勝感激。
使用'對錯誤轉到0'來禁用'On Error Resume Next'和'Err.Clear()'來清除當前錯誤。 – Lankymart