100 likes | 256 Views
Try-Catch Blocks. Exception Handling. The Try-Catch set of statements detects exceptions and takes corrective action. Exception Handling. Exception Handling. Additional Information.
E N D
Exception Handling • The Try-Catch set of statements detects exceptions and takes corrective action
Additional Information • When using multiple Catch blocks, you should always put the most common exception as the first Catch block, followed by the next likely exception, etc. • The Finally statement is optional and executes last regardless of whether the code in the Catch blocks has been executed.
Knowledge Check • Which type of exception would be detected if you use the conversion command Convert.ToInt32 to convert a non-integer value? • * • FormatException
Knowledge Check • Which type of exception would be detected in the following code: Dim intMultiple as Integer Dim intProduct as Integer intMultiple = 2000000000 intProduct = intMultiple ^ 10 * • OverflowException
Check for Knowledge • If you use multiple Catch blocks in a Try-Catch block of code, how do you determine the order of the Catch blocks?
Last ? • Where should the optional Finally block be placed in the Try-Catch block? • After the Try • After the Catch • Before the End Try