Retrieving the line# where an error occured


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Retrieving the line# where an error occured

  1. #1
    Francois Gibeau Guest

    Retrieving the line# where an error occured


    Hi All,

    I usually post and respond in the OOP chat room but this one is more general...

    Once an error occurs in VB the Err object's properties are updated. But there
    is no .LineNumber property to tell you the exact line the error comes from
    -EVEN THOUGHT the VB code window's standard tool bar indicates the Ln #,
    Col # while one is typing code (its the same tool bar that shows X,Y and
    W,H coordinates)!

    Any suggestions to get that line number???

  2. #2
    Mark Guest

    Re: Retrieving the line# where an error occured


    "Francois Gibeau" <gibeau_f@hotmail.com> wrote:
    >
    >Hi All,
    >
    >I usually post and respond in the OOP chat room but this one is more general...
    >
    >Once an error occurs in VB the Err object's properties are updated. But

    there
    >is no .LineNumber property to tell you the exact line the error comes from
    >-EVEN THOUGHT the VB code window's standard tool bar indicates the Ln #,
    >Col # while one is typing code (its the same tool bar that shows X,Y and
    >W,H coordinates)!
    >
    >Any suggestions to get that line number???


    Hi Francois,
    You can use the Erl function to return the line number that was executing
    at the time of the error. But in order for this to work, you have to have
    line numbers in your code. Try this:

    ***********************************
    Private Sub Form_Load()
    Dim x As Integer

    1 On Error GoTo Err_Form_Load

    2 x = 1 / 0
    3 x = 1 / 0
    4 x = 1 / 0

    5 Exit_Form_Load:
    6 Exit Sub
    7 Err_Form_Load:
    8 MsgBox "The following error has occured at line " & _
    Str(Erl) & vbCrLf & Str(Err.Number) & " " & Err.Description
    9 Resume Next
    End Sub

    You can number the lines manually, or you can use a third party tool to do
    it. GridLinx software make a utility call VB Builder which work nicely.
    It will also manage versioning. Check it out at:
    http:\www.gridlinx.com

    Hope this helps,
    -Mark.


  3. #3
    Mark Guest

    Re: Retrieving the line# where an error occured


    Sorry, the address is:

    http://www.gridlinx.com

    -Mark.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center