Results 1 to 9 of 9

Thread: Visual Basic 2010 - Unhandled Exceptions, Please Help

Threaded View

  1. #3
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,713

    Re: Visual Basic 2010 - Unhandled Exceptions, Please Help

    First off you should never use On Resume Next, as it is bad to ignore errors. Instead use assertion i.e.

    This is not good if the file does not exist.
    Code:
    IO.File.Delete("Somefile.txt")
    Best to check if the file exists first, this is assertion.
    Code:
    Dim fileName As String = "Somefile.txt"
    . . .
    If IO.File.Exists(fileName) Then
        IO.File.Delete(fileName)
    End If
    For unexpected exceptions you can override the default unhandled exception handler, see attached VS2010 project, compile, run outside of the IDE then inside the IDE. Next look at the error log file created in the app executable folder.

    Bottom line is write tight code, test well and when there is an unexpected error write assertion to trap for this and as a last resort use Try/Catch and never leave the Catch section empty.
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width