读书人

vbs中on error resume next用法解决思

发布时间: 2012-02-09 18:22:27 作者: rapoo

vbs中on error resume next用法
一直不明白on error resume next用法,如下面的代码,显示刷新页面5次,sub中有错误的,但是为什么错误的具体信息就是输不出来,刚开始学,请多指教,不胜感激:

On Error Resume Next
If Err.Number<>0 Then
MsgBox Err.Number&vbcr&Err.Description&vbcr&Err.Source
End If
Sub PageRefresh()
Set objExplorer = CreateObject("InternetExplorer.Application")
With objExplorer
.Navigate "http://www.a-bm.cn/Exhi_news/T164/list.html"
.......
End With
Dim i
i=0
Do
wait 10 //这句代码有误
'Wscript.Sleep 10000
'延时10s
i=i+1
objExplorer.Refresh
MsgBox i
Loop While i<5
objExplorer.Quit
End Sub
PageRefresh()

[解决办法]

VBScript code
on error resume next'就是不理是否发生错误,还要往下运行。'这句话一般放在有可能发生错误的地方。一最后发生的一个错误为准。If Err.Number <>0 Then    MsgBox Err.Number&vbcr&Err.Description&vbcr&Err.Source End If 

读书人网 >vbScript

热点推荐