Try-Catch-End Try 在 VBScript 中似乎不起作用 [英] Try-Catch-End Try in VBScript doesn't seem to work

查看:33
本文介绍了Try-Catch-End Try 在 VBScript 中似乎不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试以下代码:

Try ' DOESN'T WORK
    Throw 2 ' How do I throw an exception?
Catch ex
    'What do I do here?
End Try

但我在 catch 子句中收到错误 Statement expected.

but I'm getting the error Statement expected in the catch clause.

有谁知道我如何在 VBScript 中使用 try/catch 捕获/抛出异常?(我不是寻找带有On Error Do X的解决方案.)

Does anyone know how I can catch/throw exceptions in VBScript using try/catch? (I am not looking for solutions with On Error Do X.)

推荐答案

VBScript 没有 Try/Catch.(VBScript 语言参考.如果有试试吧,它会被列在 Statements 部分.)

VBScript doesn't have Try/Catch. (VBScript language reference. If it had Try, it would be listed in the Statements section.)

On Error Resume Next 是 VBScript 中唯一的错误处理.对不起.如果你想要 try/catch,JScript 是一个选项.它在 VBScript 所在的任何地方都受支持,并且具有相同的功能.

On Error Resume Next is the only error handling in VBScript. Sorry. If you want try/catch, JScript is an option. It's supported everywhere that VBScript is and has the same capabilities.

这篇关于Try-Catch-End Try 在 VBScript 中似乎不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆