How to get the line number
-
Hello, A quite simple question : I have add an error handler to my VB project. Everything's perfect. But when I catch a run-time error, how to get the line number where the error occurs ? I'm using VB6 and I haven't find such property on the err object. Thanks in advance !
-
Hello, A quite simple question : I have add an error handler to my VB project. Everything's perfect. But when I catch a run-time error, how to get the line number where the error occurs ? I'm using VB6 and I haven't find such property on the err object. Thanks in advance !
Broker2003 wrote: I'm using VB6 and I haven't find such property on the err object. That's because the property doesn't exist. You can't determine the line number while in the executable because that information is not saved written to the executable. The closest your going to get is the name of the class or module that generated the error. RageInTheMachine9532
-
Broker2003 wrote: I'm using VB6 and I haven't find such property on the err object. That's because the property doesn't exist. You can't determine the line number while in the executable because that information is not saved written to the executable. The closest your going to get is the name of the class or module that generated the error. RageInTheMachine9532
VB V5 used to have an undocumented function called Erl that would return it as long as you preceded each line of code with a number. Ech! To do this now days all i do is set a variable called lineNo in each function I use and incriment that as my code moves on. Then in my error handler I can simply refer to that var as the last point where I was processing. I don;t obviously do this for each and every line of code I have, but rather I number logical groups of code together.
Paul Watson wrote: "At the end of the day it is what you produce that counts, not how many doctorates you have on the wall." George Carlin wrote: "Don't sweat the petty things, and don't pet the sweaty things." Jörgen Sigvardsson wrote: If the physicists find a universal theory describing the laws of universe, I'm sure the asshole constant will be an integral part of that theory.
-
Hello, A quite simple question : I have add an error handler to my VB project. Everything's perfect. But when I catch a run-time error, how to get the line number where the error occurs ? I'm using VB6 and I haven't find such property on the err object. Thanks in advance !
Use the Erl function. But in order to get it work, you need to number your lines of code. A very useful tool is MZTools, which can do that and a lot of other very interesting stuff. (http://www.mztools.com/)