By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,652 Members | 1,911 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,652 IT Pros & Developers. It's quick & easy.

Erl

P: n/a
Visual Basic Language Reference
Erl Property
Returns an integer indicating the line number of the last executed
statement. Read-only.
Public ReadOnly Property Erl() As Integer
Remarks
If Visual Basic encounters no line numbers, it returns 0.

Sub Blah()
10 Dim rst As DAO.Recordset
20 On Error GoTo BlahErr
30 GoTo BlahExit
40 MsgBox "Yes"
BlahExit:
rst.Close
Exit Sub
BlahErr:
MsgBox "ERL returns: " & Erl _
& vbNewLine _
& vbNewLine _
& "But the Error didn't occur at :" & Erl & "!" _
& vbNewLine _
& "In fact Line " & Erl & " is Never Run!" _
& vbNewLine _
& vbNewLine _
& "Use <Ctrl><Break> to exit.", vbInformation, "FFDBA"
Resume BlahExit
End Sub

Dec 31 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a

"Lyle Fairfield" <ly***********@aim.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Visual Basic Language Reference
Erl Property
Returns an integer indicating the line number of the last executed
statement. Read-only.
Public ReadOnly Property Erl() As Integer
Remarks
If Visual Basic encounters no line numbers, it returns 0.

Sub Blah()
10 Dim rst As DAO.Recordset
20 On Error GoTo BlahErr
30 GoTo BlahExit
40 MsgBox "Yes"
BlahExit:
rst.Close
Exit Sub
BlahErr:
MsgBox "ERL returns: " & Erl _
& vbNewLine _
& vbNewLine _
& "But the Error didn't occur at :" & Erl & "!" _
& vbNewLine _
& "In fact Line " & Erl & " is Never Run!" _
& vbNewLine _
& vbNewLine _
& "Use <Ctrl><Break> to exit.", vbInformation, "FFDBA"
Resume BlahExit
End Sub


And... Just in case Someone was wondering....

This is NOT a "DAO peculiarity in A97"!

--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.
Dec 31 '05 #2

P: n/a
On 31 Dec 2005 13:13:52 -0800, "Lyle Fairfield" <ly***********@aim.com> wrote:
Visual Basic Language Reference
Erl Property
Returns an integer indicating the line number of the last executed
statement. Read-only.
Public ReadOnly Property Erl() As Integer
Remarks
If Visual Basic encounters no line numbers, it returns 0.

Sub Blah()
10 Dim rst As DAO.Recordset
20 On Error GoTo BlahErr
30 GoTo BlahExit
40 MsgBox "Yes"
BlahExit:
rst.Close
Exit Sub
BlahErr:
MsgBox "ERL returns: " & Erl _
& vbNewLine _
& vbNewLine _
& "But the Error didn't occur at :" & Erl & "!" _
& vbNewLine _
& "In fact Line " & Erl & " is Never Run!" _
& vbNewLine _
& vbNewLine _
& "Use <Ctrl><Break> to exit.", vbInformation, "FFDBA"
Resume BlahExit
End Sub


If I had to guess, I'd say the docs are simply imprecise. If one defines "the
line number of the last executed statement" to mean the number of that line or
the last line above it that has a number defined, then the code is working as
expected. The line number of "rst.Close" would then be 40 because the closest
line above it that has a number specifies 40.
Dec 31 '05 #3

P: n/a
On Sat, 31 Dec 2005 14:18:35 -0800, Steve Jorgensen
<no****@nospam.nospam> wrote:
On 31 Dec 2005 13:13:52 -0800, "Lyle Fairfield" <ly***********@aim.com> wrote:
Visual Basic Language Reference
Erl Property
Returns an integer indicating the line number of the last executed
statement. Read-only.
Public ReadOnly Property Erl() As Integer
Remarks
If Visual Basic encounters no line numbers, it returns 0.

Sub Blah()
10 Dim rst As DAO.Recordset
20 On Error GoTo BlahErr
30 GoTo BlahExit
40 MsgBox "Yes"
BlahExit:
rst.Close
Exit Sub
BlahErr:
MsgBox "ERL returns: " & Erl _
& vbNewLine _
& vbNewLine _
& "But the Error didn't occur at :" & Erl & "!" _
& vbNewLine _
& "In fact Line " & Erl & " is Never Run!" _
& vbNewLine _
& vbNewLine _
& "Use <Ctrl><Break> to exit.", vbInformation, "FFDBA"
Resume BlahExit
End Sub


If I had to guess, I'd say the docs are simply imprecise. If one defines "the
line number of the last executed statement" to mean the number of that line or
the last line above it that has a number defined, then the code is working as
expected. The line number of "rst.Close" would then be 40 because the closest
line above it that has a number specifies 40.


Yes. If
11 MsgBox "No"
is inserted before the Exit line, Erl is 11

BTW, who puts line numbers in code anymore?

Of course, if the rest of the code also was line numbered, then
50 rst.Close would have given an Erl of 50

P
Jan 1 '06 #4

P: n/a
Per Peter Sutton:
BTW, who puts line numbers in code anymore?


I do it for many routines. If your error trapping writes info to a log, it can
be useful in quickly localizing a problem
--
PeteCresswell
Jan 2 '06 #5

P: n/a
On Sun, 01 Jan 2006 20:24:24 -0500, "(PeteCresswell)" <x@y.Invalid>
wrote:
Per Peter Sutton:
BTW, who puts line numbers in code anymore?


I do it for many routines. If your error trapping writes info to a log, it can
be useful in quickly localizing a problem


It may be that you like typing more than me. However, I must admit
that on the _very_ odd occasion I have inserted a selected number of
line numbers where a recurring error has been intermittent and the
user(s) couldn't give enough information to track the problem down.

P
Jan 2 '06 #6

P: n/a
Per Peter Sutton:
However, I must admit
that on the _very_ odd occasion I have inserted a selected number of
line numbers where a recurring error has been intermittent and the
user(s) couldn't give enough information to track the problem down.


Once you start logging to a text file, it really grows on you. There *much*
less of having to subject the user to questioning trying to find out exactly
what happened.
--
PeteCresswell
Jan 2 '06 #7

P: n/a
If you get utility such as MZTools it'seasy to add and remove lin numbers
from VB and VBA procs.

Personally I on;y add them whene there is a problem whih is difficult to
track as well but they are very useful.

--------
Terry Kreft

"Peter Sutton" <ps******@killspam.com.au> wrote in message
news:lb********************************@4ax.com...
On Sun, 01 Jan 2006 20:24:24 -0500, "(PeteCresswell)" <x@y.Invalid>
wrote:
Per Peter Sutton:
BTW, who puts line numbers in code anymore?


I do it for many routines. If your error trapping writes info to a log, it canbe useful in quickly localizing a problem


It may be that you like typing more than me. However, I must admit
that on the _very_ odd occasion I have inserted a selected number of
line numbers where a recurring error has been intermittent and the
user(s) couldn't give enough information to track the problem down.

P

Jan 2 '06 #8

P: n/a
Brain surgeons use scalpels as well.

Jan 3 '06 #9

P: n/a

"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:TF********************@karoo.co.uk...
If you get utility such as MZTools it'seasy to add and remove lin numbers
from VB and VBA procs.

Personally I on;y add them whene there is a problem whih is difficult to
track as well but they are very useful.

--------
Terry Kreft


It seems apparent, from the variety of sentiments in this thread, that not
everyone shares the same opinion about the use of line numbers. I guess it
comes down to a "style" peference. Personally, I use them only for
debugging. For example, a situation where users report intermittent errors
that I can't reproduce and the Err.Description isn't enough to identify the
exact source of the error.

I too use MZTools, it makes it extremely easy to both add and remove the
numbers. I prefer not to leave the numbers in the procedures once the
debugging is completed. The problem is, as was pointed out in an earlier
thread on a similar topic, that MZTools only works with A2K and higher.

--
Randy Harris
tech at promail dot com
I'm pretty sure I know everything that I can remember.

Jan 3 '06 #10

P: n/a
Both rkc and I contributed [for free] line number code and I believe
such code or add-in exists at the mvp site? Don't know about rkc's but
mine removes numbers on demand, or removes numbers of previously
numbered lines before numbering them again. Is mine tested? No! Is the
code right there so anyone can modify it to meet his/her needs? Yes.
I think mine works with Access 97 but I have no way to check.

Jan 3 '06 #11

P: n/a
http://www.mvps.org/access/downloads/wzComment.zip

--
Terry Kreft
"Lyle Fairfield" <ly***********@aim.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Both rkc and I contributed [for free] line number code and I believe
such code or add-in exists at the mvp site? Don't know about rkc's but
mine removes numbers on demand, or removes numbers of previously
numbered lines before numbering them again. Is mine tested? No! Is the
code right there so anyone can modify it to meet his/her needs? Yes.
I think mine works with Access 97 but I have no way to check.

Jan 3 '06 #12

P: n/a
New laptop, new keyboard response and the keys have been moved around (my
excuse anyway <g>).

--
Terry Kreft

"Terry Kreft" <te*********@mps.co.uk> wrote in message
news:TF********************@karoo.co.uk...
If you get utility such as MZTools it'seasy to add and remove lin numbers
from VB and VBA procs.

Personally I on;y add them whene there is a problem whih is difficult to
track as well but they are very useful.

--------
Terry Kreft

"Peter Sutton" <ps******@killspam.com.au> wrote in message
news:lb********************************@4ax.com...
On Sun, 01 Jan 2006 20:24:24 -0500, "(PeteCresswell)" <x@y.Invalid>
wrote:
>Per Peter Sutton:
>>BTW, who puts line numbers in code anymore?
>
>I do it for many routines. If your error trapping writes info to a log, it can >be useful in quickly localizing a problem


It may be that you like typing more than me. However, I must admit
that on the _very_ odd occasion I have inserted a selected number of
line numbers where a recurring error has been intermittent and the
user(s) couldn't give enough information to track the problem down.

P


Jan 3 '06 #13

This discussion thread is closed

Replies have been disabled for this discussion.