+ Reply to Thread
Results 1 to 4 of 4

knowing error line and module name

  1. #1
    x taol
    Guest

    knowing error line and module name



    i wanna know error line and module name when outbreak of error in any
    module.

    Sub test()
    On Error GoTo erohandle:
    ~~~~~
    ~~~~~
    Exit Sub
    erohandle:
    MsgBox "the current module name is " & xxxx & vbCrLf & "the line number
    is " & yyyyy
    End Sub


    *** Sent via Developersdex http://www.developersdex.com ***

  2. #2
    Tom Ogilvy
    Guest

    Re: knowing error line and module name

    look at help on erl - however you have to have explicit line numbers written
    into your code (the old Basic way).

    Other than that, you will have to code it yourself.

    --
    Regards,
    Tom Ogilvy

    "x taol" <tomi3440@yahoo.com> wrote in message
    news:%23JA8z%23yCGHA.916@TK2MSFTNGP10.phx.gbl...
    >
    >
    > i wanna know error line and module name when outbreak of error in any
    > module.
    >
    > Sub test()
    > On Error GoTo erohandle:
    > ~~~~~
    > ~~~~~
    > Exit Sub
    > erohandle:
    > MsgBox "the current module name is " & xxxx & vbCrLf & "the line number
    > is " & yyyyy
    > End Sub
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***




  3. #3
    Bob Phillips
    Guest

    Re: knowing error line and module name

    There is no automated way, but you could the module name in a constant and
    scatter line numbers periodically through the procedure, and then use the
    Erl function to get the last line
    number encountered before the error was raised. E..g,

    Here is an example

    Sub TestErrorLineNumber()
    Const sModule As String = "Module1"

    On Error GoTo ErrHandler:
    10:
    ' some code
    20:
    ' more code
    Err.Raise 1
    'etc.
    Exit Sub
    ErrHandler:
    MsgBox "Error: " & Err.Number & " " & Err.Description & vbNewLine & _
    "in module: " & sModule & " in project: " & Err.Source & vbNewLine &
    _
    "around the following line: " & Erl
    End Sub

    You could also add the procedure name.


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "x taol" <tomi3440@yahoo.com> wrote in message
    news:%23JA8z%23yCGHA.916@TK2MSFTNGP10.phx.gbl...
    >
    >
    > i wanna know error line and module name when outbreak of error in any
    > module.
    >
    > Sub test()
    > On Error GoTo erohandle:
    > ~~~~~
    > ~~~~~
    > Exit Sub
    > erohandle:
    > MsgBox "the current module name is " & xxxx & vbCrLf & "the line number
    > is " & yyyyy
    > End Sub
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***




  4. #4
    Robin Hammond
    Guest

    Re: knowing error line and module name

    The MZTools add in is quite useful for this.

    There is a routine that add's/removes line numbers to your code, and a
    routine that will add an error handler to a module with the name of the
    module included automatically.

    Robin Hammond
    www.enhanceddatasystems.com

    "x taol" <tomi3440@yahoo.com> wrote in message
    news:%23JA8z%23yCGHA.916@TK2MSFTNGP10.phx.gbl...
    >
    >
    > i wanna know error line and module name when outbreak of error in any
    > module.
    >
    > Sub test()
    > On Error GoTo erohandle:
    > ~~~~~
    > ~~~~~
    > Exit Sub
    > erohandle:
    > MsgBox "the current module name is " & xxxx & vbCrLf & "the line number
    > is " & yyyyy
    > End Sub
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1