如何捕获异常(内部VB或DLL错误调用WIN32 API)无论VB6.0中的具体子或函数如何 [英] How Can I Catch An Exception(Inner VB Or Dll Error Calling WIN32 API) Regardless Of A Concrete Sub Or Function In VB6.0

查看:309
本文介绍了如何捕获异常(内部VB或DLL错误调用WIN32 API)无论VB6.0中的具体子或函数如何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

众所周知,我们可以使用这个语句 - On Error GoTo ...来捕获VB6.0中的运行时错误。但是,如果我以这种方式编程,我必须在每个Sub或Functon中编写许多类似的代码。我认为这很耗时而且很无聊!所以,这里有一个问题,我们可以在一个子或功能中完成所有功能,甚至在另一个过程中(例如BugReport.exe)。我非常喜欢开始一个新进程来记录我的目标进程的详细运行时参数,并在必要时将它们保存到日志中,但我是Programming With VB的初学者。那么,有人能给我一些实际的建议吗?非常感谢!

As we all know, we can catch a runtime error in VB6.0 using this statement —— "On Error GoTo ...". However, if I programm in this manner, I have to write a lot of similiar code in each Sub Or Functon. I consider it time-consuming and really boring! So,here comes a question, "Can We Do It All In One Sub Or Function Or Even In Another Process(like "BugReport.exe")". I very much prefer starting a new process to record detailed runtime parameters of my target process and save them to a log if necessary, but I am a beginner of Programming With VB. So, can anybody give me some pratical suggestions? Much appreciated!

推荐答案

要盲目回答你的问题,我可以指导你这个旧文章 [ ^ ]



如果您真的想要,可以在完全独立的activeX dll中进行错误处理...参见如何创建activeX dll [ ^ ],但你可能最好只在一个单独的.bas模块中使用集中式错误功能来包含在你的项目中。



说完所有那...你确实意识到VB6不再受支持了吗?



除非有限制(例如你工作的公司已经在VB6中有代码库,你必须继续保持它,然后我会建议你升级到.NET语言。 Express版本是免费的(与VB6不同) - http://www.visualstudio.com/downloads/download- visual-studio-vs [ ^ ],具有更长的使用寿命,并具有更好的错误处理能力
To blindly answer your question I can direct you to this old article[^]

You could have the error handling in a completely separate activeX dll if you really wanted to ... see how to create an activeX dll[^], but you're probably better off just having the centralised error function in a separate .bas module to be included in your projects.

Having said all that ... you do realise that VB6 is no longer supported?

Unless there are constraints (such as the corporation you work for already has a code base in VB6 and you have to continue to maintain it), then I would advise you to "upgrade" to a .NET language. The Express versions are free (unlike VB6) - http://www.visualstudio.com/downloads/download-visual-studio-vs[^], will have greater longevity, and have better error-handling capabilities


这篇关于如何捕获异常(内部VB或DLL错误调用WIN32 API)无论VB6.0中的具体子或函数如何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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