VB Error Object

Posted on 2005-05-06
Last Modified: 2010-05-02
Hi everyone!
    Is there any way that i can get the line number where last error has occured in an ActiveX Dll. i m calling that dll from an ASP page. i have look into "err" object but it provides description and some other properties but not the line number.

Question by:hammadraza
    LVL 10

    Expert Comment

    To get the line number you need to use erl.

    In order for erl to contain the line number, you need to add line numbering to each line of code in the dll. There are numerous free tools (VB addins) that will add the line numbering for you.
    LVL 10

    Expert Comment

    Here is a link to a line numbering tool (plus it has a load of other functionality):
    LVL 1

    Author Comment

    Is it a VB6 object?
    LVL 10

    Accepted Solution

    It's more like a vb variable.

    In the dll you will need to pass the value of erl into a variable the ASP page can access.
    For example you could create a dll function to return the erl or raise an error from within the dll that includes the line number.
    For example:
    Err.Raise Err.Number, "MyDll.SomeFunction", Err.Description & " at line " & Erl
    LVL 7

    Expert Comment

    Here's a brief example:

    Private Sub Form_Load()
        On Error GoTo err

    1:     Me.Caption = 5 / 5
    2:     Me.Caption = 5 / 4
    3:     Me.Caption = 5 / 3
    4:     Me.Caption = 5 / 2
    5:     Me.Caption = 5 / 1
    6:     Me.Caption = 5 / 0

        Exit Sub
        MsgBox "Error " & err.Number & ": " & err.Description & vbNewLine & "Line #: " & erl
    End Sub

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
    Article by: Martin
    Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now