views:

540

answers:

3

We have multiple vb projects.We want to put error handlers in all functions, and error handler should write to a file.Are there any tools available - we have looked at codesmart and vbwatch.

+2  A: 

Here's a freeware program:
http://wareseeker.com/Software-Development/automatic-error-handling-pro-1.1.0.zip/238557

and here's some source code for doing it yourself:
http://www.nigelrivett.net/VB/VBAddErrorHandling.html

gkrogers
thks, will chk out
+5  A: 

MZ-Tools, which is free and very easy to install, is often recommended:

Supported Microsoft Development Tools

  • Visual Studio 2008 (except Express editions)
  • Visual Studio 2005 (except Express editions)
  • Visual Studio .NET 2003
  • Visual Studio .NET 2002
  • Visual Basic 6.0
  • Visual Basic 5.0
  • VBA Editor (Office 2000-2007 or others)

Supported Programming Languages

  • Visual C#
  • Visual Basic .NET
  • Visual C++ (partial support, most features)
  • Visual J#
  • Visual Basic 6.0 and 5.0
  • Visual Basic for Applications (VBA)
Remou
Anyone programming in vb6 should definitely be using this add on and not just for its usefulness in adding code and line numbers for error handling
kjack
IMHO VB6 isn't installed until you've installed MZTools. It's free too (Remou can you edit your answer and mention that)
MarkJ
+1  A: 

Make sure you test performance before putting it in all procedures. Our Error Handler solution (VBRig) noticeably impacted math calculation and screen redraws in our CAD/CAM application. It wasn't badly written but the addition of doing the logging hundreds of time added up.

We switched to use error handling in all event routines and selected other area. While not ideal from a design standpoint it brought performance back up to what it needed to be.

RS Conley
I'd have thought the overhead would be negligible unless your code was actually raising lots of errors. Which I believe would cause performance problems in itself. Presumably you were only logging if errors actually happen?
MarkJ
My CAD/CAM applications does 3D calculations to unfold shapes as well as dynamic drawing of the screen. The tiny bit of overhead of logging procedures in Visual BASIC 6 adds up to enough to visibly slow the process.
RS Conley
Like a many things in programming it not an absolute. You need to use your best judgment.
RS Conley
In visual basic 6 you need to manually log each procedure if you want a stack trace.
RS Conley
We put an error handler in each routine which traps the error, and then raises it again, appending the name of the routine to the error details. The final routine (event handler or sub Main) actually logs the error. Result: a stack trace, built only when errors occur. No run-time penalty otherwise.
MarkJ
Alternatively (if you are hardcore) looks like you can create stack traces in VB6 with no run-time penalty like this (I haven't tried it): http://www.codeproject.com/KB/exception/RealTimeDebugger.aspx
MarkJ
We put an error handler ... that is just elegant. Thanks for the tip.
RS Conley