VBA-错误GoTo ErrHandler: [英] VBA - On Error GoTo ErrHandler:

查看:219
本文介绍了VBA-错误GoTo ErrHandler:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于VBA中的错误处理,我有一个简单的问题。
我知道如何使用 On Error GoTo ErrHandler 语句,但是我宁愿使用预制的VBA消息,而不是在指定标签上使用自己的代码。在C#中是这样的:

I have a simple question about error-handling in VBA. I know how to use the On Error GoTo ErrHandler statement but instead using my own code at the specified label, I would rather use a prefabricated VBA-message. Something like this in C#:

catch(Exception ex){
    Console.Writeline(ex.Message);
}


推荐答案

在您的错误处理程序代码中,可以访问 Err.Number Err.Description 。错误消息中没有错误处理的描述,因此等同于代码示例中的 ex.Message

In your error handler code your can access the Err.Number and Err.Description. The Description in the error message you would have seen without error handling, so is the equivalent of ex.Message in your code sample.

这篇关于VBA-错误GoTo ErrHandler:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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