Capturing Line Nos in Try Catch Exception

Aarvee

Well-known member
Joined
Sep 21, 2005
Messages
50
Location
Bangalore, India
Programming Experience
Beginner
We have written a routine to capture all relevant information of errors comingn in the Try Catch Exception Block for later viewing and debugging. However one item we are not able to capture is the line number. Does anyone know how to capture this so that we can precisely state in which line the error came and it will help in debugging more effectively ?

Thanks

Varadarajan R
 
maybe you can use this, ive writen it in a hury, im sure it can be shorter.

VB.NET:
        Try
            Dim i As Integer
            i = i / 0
        Catch ex As Exception
            'MessageBox.Show(ex.ToString)
            Dim LineNumber As String
            LineNumber = ex.ToString.Substring(ex.ToString.LastIndexOf("line"))
            LineNumber = LineNumber.Replace("line", "")
            LineNumber = LineNumber.Trim
            MessageBox.Show(LineNumber)
        End Try
 
Back
Top