Results 1 to 4 of 4

Thread: Error Handling

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Location
    Denver, CO
    Posts
    10

    Exclamation

    For those of you who log errors, here's a handy little way to find out what line number errored : Erl
    Here's an example(this code is intentionally set up to error):
    [code]
    Private Sub Command1_Click()
    1 On Error GoTo Hell
    Dim x() As String

    2 x(1) = "This is a test"
    3 Exit Sub

    Hell:
    4 Debug.Print "Error- " & Err.Description & " at Line Number: " & Erl
    End Sub
    [\code]

    If your lines aren't numbered, it'll return a 0. There's a cool little tool out there that will number all of your lines for you, called vbAdvantage. Just thought I'd share since there's nothing about it in the MSDN Library

  2. #2
    Addicted Member S@NSIS's Avatar
    Join Date
    Aug 2000
    Location
    Stoke-On-Trent, England
    Posts
    243

    Thumbs down Return of the line numbers (Noooooooooo!!!!!!)

    Why would we want to number our lines when VB gives us the option of debugging and stepping through our code one line at a time (thus seeing exactly which line our error occurs at).

    No offence healy, but reverting back to using line numbers is not the way to go about debugging VB programs

    Shaun
    Web/Application Developer
    VB6 Ent (SP5), Win 2000,SQL Server 2000

  3. #3
    Guest

    Re: Return of the line numbers (Noooooooooo!!!!!!)

    Originally posted by S@NSIS
    Why would we want to number our lines when VB gives us the option of debugging and stepping through our code one line at a time (thus seeing exactly which line our error occurs at).

    No offence healy, but reverting back to using line numbers is not the way to go about debugging VB programs

    Shaun
    Shaun, it ain't that bad 'a code, I have seen people (or someone) wanting to do this before. So, whoever they were (or are), if it works, you have found the code you need.

    [Edited by Matthew Gates on 10-03-2000 at 06:26 PM]

  4. #4

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Location
    Denver, CO
    Posts
    10
    For the code I write, I actually open a text file for the purposes of logging. I also have an error handler in almost every procedure.
    When a client calls up and tells me that one of our apps is having a problem, I find it really nice to know why and the exact line of code the problem is coming from...
    Other than that, I can see no other practical reason for line numbers.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width