Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to get the line number

How to get the line number

Scheduled Pinned Locked Moved Visual Basic
questionhelptutorial
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Broker2003
    wrote on last edited by
    #1

    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 !

    D S 2 Replies Last reply
    0
    • B Broker2003

      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 !

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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

      R 1 Reply Last reply
      0
      • D Dave Kreskowiak

        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

        R Offline
        R Offline
        Ray Cassick
        wrote on last edited by
        #3

        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.


        1 Reply Last reply
        0
        • B Broker2003

          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 !

          S Offline
          S Offline
          Skippy II
          wrote on last edited by
          #4

          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/)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups