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
Note the line wrapping on line 760.