使用VBScript Err对象进行错误检查

时间:2015-08-25 20:42:37

标签: vbscript error-handling

使用以下访问html span元素的代码块,我无法检查错误。当我将输入框留空并按“确定”时,Err.Number的值不会改变。我启用了用户错误检查(On Error Resume Next),我正在检查以确保Err.Number不等于0(错误发生)。抛出错误,但Err.Number的值没有改变,当On Error Resume Next打开时以及关闭时都会发生这种情况。顺便问一下,Err.Number的默认值是多少?清除Err对象后,该值与Err.Number的值有何不同?如果我做错了或说明任何错误的信息,请通知我。

On Error Resume Next
Dim updateRate
updateRate = 0
RatePrompt()
Sub RatePrompt
    updateRate = InputBox("Please enter an update rate (milliseconds)",     "Update Rate")

If Err <> 0 Then
    Err.Clear()
    MsgBox "No Input Was Specified. Please Specify An Input."
    RatePrompt()
Else If updateRate > 2000 then
    rateDecision = MsgBox ("Consider entering a lower update rate" & vbCrLf & "Would you like to revise update rate?", _
    vbYesNo, "Quiclock Alert")
    If rateDecision = vbYes then 
        RatePrompt()
    End If
Else If updateRate < 0 then
    MsgBox "Update Rate Not Valid. The Default Value of 0 Milliseconds Will Be Used."
    updateRate = 0
Else If updateRate = "" then
    MsgBox "Update Rate Adjustment Cancelled. The Default Value of 0 Milliseconds Will Be Used."
    updateRate = 0
Else 

End If
End If
End If
End If
End Sub

TimerStart()

Sub TimerStart
    timerID = window.setTimeout("TimeUpdate", updateRate, "VBScript")
End Sub

Sub TimeUpdate
    clockOutput.innerHTML = Time()
    window.clearTimeout(timerID)
    TimerStart()
End Sub

我花了很多时间研究这个问题,但还没有得出结论。谢谢你的帮助。

0 个答案:

没有答案