On Error Resume Next


On Error Resume Next

Unhandled Error Capture

As I mentioned earlier, it's a good idea to include a global error handler in your code, in case some error gets past your defenses. To include this code, display all files in the Solution Explorer using the "Show All Files" button, open the ApplicationEvents.vb file, and add the following code to the MyApplication class.

Insert Snippet

Insert Chapter 9, Snippet Item 4.


Private Sub MyApplication_UnhandledException( _       ByVal sender As Object, ByVal e As Microsoft. _       VisualBasic.ApplicationServices. _       UnhandledExceptionEventArgs) Handles _       Me.UnhandledException    ' ----- Record the error, and keep running.    e.ExitApplication = False    GeneralError("Unhandled Exception", e.Exception) End Sub 


Because we already have the global GeneralError routine to log our errors, we might as well take advantage of it here.

That's it for errors. In the next chapter, which covers database interactions, we'll make frequent use of this error-handling code.




Start-to-Finish Visual Basic 2005. Learn Visual Basic 2005 as You Design and Develop a Complete Application
Start-to-Finish Visual Basic 2005: Learn Visual Basic 2005 as You Design and Develop a Complete Application
ISBN: 0321398009
EAN: 2147483647
Year: 2006
Pages: 247
Authors: Tim Patrick

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net