ITSourceCode.com

We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

35-Try Catch

In programming, there are Exceptions that handle errors and other exceptional events. As a programmer, it is the best way to used it to deal with unhandled exceptions. In Visual Basic, there is a try catch that handle errors. Try…Catch statement composed of a Try block and followed by one or more Catch clauses, which stated the handlers for various exceptions.

 

syntax

Try
    [ tryStatements ]
    [ Exit Try ]
[ Catch [ exception [ As type ] ] [ When expression ]
    [ catchStatements ]
    [ Exit Try ] ]
[ Catch ... ]
[ Finally
    [ finallyStatements ] ]
End Try

example:

  1. <pre>Try
  2.     Process.Start("http://www.itsourcode.com")
  3. Catch ex As Exception
  4.     MsgBox("The page cannot be loaded because " &amp; vbCrLf &amp; ex.Message)
  5. End Try
Facebook Comments

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked *

ITSourceCode.com © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!