On Error Goto ....

MTSkull

Centurion
Joined
Mar 25, 2003
Messages
151
Location
Boulder, Colorado
I notice in the error object we have an err.erl property, which the program tells me is the line where the error occurred. However when my program is running and calls this property it is always passing zeros. Is this an unimplemented feature or do I have to do something special to make it work?

Brian
 
Use Try..Catch
Visual Basic:
Try
    'Code that can crash

Catch IOExc as IO.IOException
    Messagebox.Show("File Error: " & IOExc.Message)
Catch Exc as Exception
    Messagebox.Show("General Error: " & Exc.Message)
End Try
 
Yeah, avoid On Error Goto. Structured Exception Handling is the way to go.

To get the line number of the offending code, you can use the StackFrame class. There's a good sample from the 101 VB.NET Samples available from MS.
 
Back
Top