35-Try Catch

0
293

This Visual Basic Tutorial is all about 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

 

Readers might read also:

 

 

Facebook Comments
(Visited 20 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here