如何处理在VB脚本错误 [英] How to handle errors in VB Script
本文介绍了如何处理在VB脚本错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个VB脚本。我需要登录一个文件中的错误信息。我需要登录像错误编号错误描述并在其中子程序请问出错每信息。
I am having an VB Script. I need to log the error information in a file. I need to log every information like error number error description and in which sub routine does the error occured.
请提供一些code
推荐答案
有关的错误在VBScript处理使用在错误clausule。
有3种方法,如何处理错误:
For error handling in VBScript is used "On Error" clausule. There are 3 ways, how to handle errors:
- 在错误继续下一步''忽略错误
- 在错误转到0''删除错误handlning
- 在错误转到的HandleError''的错误将code跳转到指定的信号
样品:
On Error Resume Next '' ignore errors
SomeIgnorableFunction()
On Error GoTo 0 '' removes error ignoring
SomeImportantFunction()
On Error GoTo HandleError '' on error will code jump to specified signal
Dim a
a = 15 / 0
GoTo Finish '' skips error handling
HandleError:
Dim msg
Set msg = Err.Description & vbCrLf & Err.Number
MsgBox msg
Finish:
'' there is end of sciprt
这篇关于如何处理在VB脚本错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文