IN THE SPOTLIGHT: MDE to MDB Conversion Service
(also supports: ACCDE to ACCDB, ADE to ADP, etc)
IN THE SPOTLIGHT: Access Database Repair Service
An in-depth repair service for corrupt Microsoft Access files
IN THE SPOTLIGHT: vbWatchdog
VBA error handling just got easier...
" vbWatchdog is off the chart. It solves a long standing problem of how to consolidate error handling into one global location and avoid repetitious code within applications. "
- Joe Anderson,
Microsoft Access MVP
Meet Shady, the vbWatchdog mascot watching over your VBA code →
(courtesy of Crystal Long, Microsoft Access MVP)
IN THE SPOTLIGHT: vbMAPI
An Outlook / MAPI code library for VBA, .NET and C# projects
Get emails out to your customers reliably, and without hassle, every single time.
Use vbMAPI alongside Microsoft Outlook to add professional emailing capabilities to your projects.
IN THE SPOTLIGHT: Code Protector
Standard compilation to MDE/ACCDE format is flawed and reversible.
It is often beneficial to have line-numbering in VB applications so that you can identify the exact line number where an exception occurs.
vbWatchdog removes the need to manually add any line numbering to your sourcecode by providing built-in detection of the line number, obtained from the compiled debug information already stored in your applications.
Normally, to add line numbering to VB code, we have to do something like this:
Public Sub A() 1 On Error GoTo ErrorHandler 2 3 Debug.Print 1 / 0 4 5 Exit Sub ErrorHandler: MsgBox "Error line number: " & Erl End Sub
As you can see, trying to add line numbers like this makes writing code more difficult to write and maintain.
Also, adding explicit line numbers like this does bloat the application - simply because of all the extra data that is being stored for every single line of source code.
Fortunately we've come up with a much better line numbering system...
Wouldn't it be great if we could identify the line number from the compiled code, without actually having to write any line numbers?
Well that's exactly how the line numbering system in vbWatchdog works! When an error occurs, internally we parse through the PCode (compiled code) and can very accurately determine the line number that caused the error.
In your global error handler, use ErrEx.SourceLineNumber to get the line number (or ErrEx.CallStack.LineNumber when iterating through the call stack)
This feature works equally well for both fully compiled projects (like .MDE Access database applications) as well as normal semi-compiled VBA projects (like .MDB Access database applications).
Tip: The line number that is referred to here does not count any white-space in the source code, nor does it count any lines that don’t have any code (e.g. Dim statements, comment lines etc).
Next: Easily determining the line numbers from within the VBE code pane...
vbWatchdog comes complete with a COM add-in that provides you with a new menu bar button in the VB IDE which enables you to very clearly see the line numbers in your source code.
By pressing the ‘Toggle SourceLineNumbers’ button, you will see the following extra bar added to your codepane:
You might wonder how you can convert the source line number indicated by ErrEx.SourceLineNumber into the actually line of code (e.g. for displaying the code in your error dialog).
(In the above example, #10 is the SourceLineNumber and ‘Debug.Print 1/0’ is the source code at line
10 in the subroutine called TestLineNumbering)
For this purpose, we have provided ErrEx.SourceLineCode and ErrEx.CallStack.LineCode - these properties simply lookup the procedure source code and return the line of code as a string expression (as per the dialog example above).
For fully compiled projects (such as Access MDE / ACCDE applications), ErrEx.SourceLineCode will return a blank string since the source code is not available. In this scenario, use ErrEx.SourceLineNumber instead to identify the line of error in your source code.
iTech Masters | VAT: GB202994606 | Terms | Sitemap | Newsletter