VBA错误“Bubble Up” [英] VBA Error "Bubble Up"

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

问题描述

我没有阅读太多,但是以下链接中的作者建议我不要在VBA中使用冒泡来集中错误处理。



Excel编程周末崩溃课程通过Google图书



但是我不知道为什么他建议这个,他并没有真正的解释。



有人可以告诉我为什么我应该在每个程序中进行错误处理,而不是使用起泡?或者至少你知道作者为什么不这么说?



谢谢。

解决方案/ div>

我不知道VBA的默认错误处理是什么,但是由于它的Visual Basic应用程序,并且这些应用程序包括诸如excel和word之类的东西,我假设只出现一个对话框,不会对于用户有帮助。



我假设作者被代码没有处理错误,所以他现在建议所有的程序来处理错误。



完整的答案是,您必须注意可能发生的每个错误,并且有代码来处理它,无论它是否尽可能低(您可能不知道该做什么),或尽可能高(这意味着编写错误处理代码的努力较少,但不知道错误发生的原因),或策略性地(只是在正确的地方,您应该能够从最常见的错误中恢复)或只是无处不在(这可能只是太多的发展


I haven't read much about it, but the author at the link below recommends that I don't use "bubble up" to centralize error handling in VBA.

Excel Programming Weekend Crash Course via Google Books

But I'm not sure why he recommends that, and he doesn't really explain.

Can someone tell me why I should put error handling in EVERY procedure instead of using "bubble up"? Or at least, do you know why the author says not to?

Thanks.

解决方案

I'm not sure what the default error handling of VBA is, but since its Visual Basic for Applications, and those applications include things like excel and word, I assume just a dialog box will appear which will not be helpful to the user.

I assume that the author has been bitten by code not handling errors so he now recommends all procedures to handle errors.

The full answer is that you have to be aware of every error that can occur and to have code in place to handle it, whether it is as low as possible (where you may not know what to do), or as high as possible (which means less effort writing error handling code, but not knowing why the error occurred), or strategically (which is just in the right places where you should be able to recover from most common errors) or just everywhere (which may be just too much development effort).

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

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