VB/VBA line numbers

So you're looking at this posting and thinking "how retro".  What is that old fart Tony up to?   Well, yes, I did use line numbers a lot when I first started as a programmer in this business almost thirty years ago.  The IBM 5110 computer booted from 32 Kb of ROM, ran in 32 Kb of RAM and had two eight inch floppy drives.  Basic on that system used line numbers and had variable names that were either a single letter or a single letter and a digit.  For example A or Z9.  

Among other things we ran clients with a complete General Ledger, Accounts Receivable and Accounts Payable on that system.   I also worked on a payroll system which had 700 employees.

But these days?  Well, yes.  I got a email about my Auto FE Updater stating Type Mismatch in one subroutine for two PCs at a location in Australia.    All the other PCs are running just fine.  That's a pretty generic message so how do I debug that?  I decided to add line numbers using MZTools and email the person a special copy of the Auto FE Updater.

MZTools has a very handy command button which adds line numbers to every executable line of code in a function or subroutine and another command button to remove them.  

Not surprising there is nothing in the help text so I had to do some searching but I found the key system defined variable Erl.   So the code looks like the following.

740       FindMatchingMSAccessEXE = True

750       Exit Function
760       Call ShowMsgBoxForm("1018 - The following problem occurred in routine 'FindMatchingMSAccessEXE' " & _
              "Line Nbr: " & Erl & vbCrLf & vbCrLf & Err.Description)
770       Exit Function

End Function

Note the line wrapping on line 760.

Published Mon, Apr 28 2008 20:29 by Tony
Filed under: ,


# re: VB/VBA line numbers

I've been using MZTools for over a year now.  It's a great utility and does much more that line numbers?

Tuesday, April 29, 2008 10:10 AM by Dan

# re: VB/VBA line numbers

Agreed MZTools is a very nice utility.  I particularly like using the procedure callers button.   That is locate all the lines of code that call the particular procedure you are viewing.

Tuesday, April 29, 2008 6:43 PM by Tony

# re: VB/VBA line numbers

Just installed MZTools 5 minutes ago.

Thank you!

Thank you!

Thank you!

Monday, May 03, 2010 8:41 AM by Bryan

# re: VB/VBA line numbers

Tony, thanks for pointing out MZTools, it's exactly what I needed. So many useful bits, and is going to save me a LOT of time on this project.

Tuesday, June 22, 2010 10:34 PM by Bob

Leave a Comment

If you can't read this number refresh your screen
Enter the numbers above: