Results 1 to 8 of 8

Thread: Error Handle

  1. #1

    Thread Starter
    Addicted Member Tiovital's Avatar
    Join Date
    Apr 2000
    Posts
    249
    Hi,
    I am using "On Error GoTo ErrorHandler", Is there a way to find out in exactly in What command the error has occured?
    The line number?

    Regards

  2. #2
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455
    Hello Tiovital,

    I allways removing temporary the "On Error" statement.
    Lets happen the situation where the error occures. Vb will show you the error line.


    Michelle.

  3. #3
    Addicted Member
    Join Date
    Jul 2000
    Location
    Scotland
    Posts
    184
    I use the following to 'break in' to the code on an error. Insert a zero and comment out the handler Label.

    On Error GoTo 0 'Error_handler

    Then when I'm done, I delete the (0 ') and use my error handler.

  4. #4
    Guest
    You can find the description of an Error, use the Err object and track it down judging by what each statement does.

    Code:
        On Error GoTo ErrorHandler
        
        'Generate an Error
        Err.Raise 6
        
        Exit Sub
    
    ErrorHandler:
    'Display a MessageBox with a description of the Error
    MsgBox Err.Description

  5. #5

    Thread Starter
    Addicted Member Tiovital's Avatar
    Join Date
    Apr 2000
    Posts
    249
    Hi,
    Thanks for the info, But i know all that, I just want to know if there is a method to know - in run time - the problematic line, Thats all.
    Regards

  6. #6
    Guest
    Tiovital, VB automatically select the line in which the error occured, as Michelle said.

    And Megatron's way should tell you what error it was that occurred. If you want to know the number of the error the occured, than use Err.Number.

    Code:
    On Error GoTo ErrorHandler
    Error 6
    Exit Sub
    ErrorHandler:
    MsgBox "Error " & Err.Number & Chr(58) & Chr(32) & Err.Description
    [Edited by Matthew Gates on 08-08-2000 at 01:55 AM]

  7. #7

    Thread Starter
    Addicted Member Tiovital's Avatar
    Join Date
    Apr 2000
    Posts
    249
    Matthew,
    Can You tell What line-number Faild? What instracution number failed? (not the err.number)

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Using Labels you can determine the error line on which error was caused
    Code:
    Private Sub Form_Load()
        On Error Resume Next
    15:     Err.Raise 10
        MsgBox Erl
    End Sub
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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