gpt4 book ai didi

vbscript - 如何在 VBScript 脚本中断言?

转载 作者:行者123 更新时间:2023-12-02 21:38:56 25 4
gpt4 key购买 nike

有什么好的使用方法assertsVBScript脚本?

是否有内置功能或者必须对其进行模拟?最佳实践是什么?

一个应用程序是在开发过程中测试对象是否Nothing

最佳答案

一个可操作的答案(对于其他可能需要它的人来说)是定义这个函数,来自 Rosetta Code :

    sub Assert( boolExpr, strOnFail )
if not boolExpr then
Err.Raise vbObjectError + 99999, , strOnFail
end if
end sub

调用:

    Set obj2 = Nothing
Assert Not obj2 Is Nothing, "obj2 is Nothing!"

输出:

    someScript.vbs(17, 3) (null): obj2 is Nothing!

关于vbscript - 如何在 VBScript 脚本中断言?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2302402/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com