Select to view content in your preferred language

Displaying the run-time error's line number in VB.NET

582
1
09-14-2010 04:51 AM
MeToo
by
Deactivated User
I am porting a large VB6 ArcGIS Desktop application to VB.NET and AO Add-In. The latter is new to me. I really liked the errorhandler module that came with the VB6 SDK that reported the run-time error's line number. What's the equivalent in VB.NET? I don't see that option with the Try... Catch... Finally statement.

Thanks.
0 Kudos
1 Reply
MeToo
by
Deactivated User
I got the answer to my own question: ex.ToString where ex is the exception object.


Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  Try
   Dim x As Integer = 5
   Dim y As Integer = 0
   Dim result As Integer
   result = x / y
  Catch ex As Exception
   MessageBox.Show("ex.ToString: " & ex.ToString)
  End Try
End Sub
End Class

I hope this helps others.
0 Kudos