It is true that multiple Catch blocks can be defined for a single Try block where each Catch block will catch a particular class of exception. When is this useful? Discuss best practices in coding multiple Catch blocks in this instance, and walk through an explanation of how these multiple Catch blocks function in the flow of the program.

What will be an ideal response?

This approach is useful when you want to state which type of error occurred and tell users the mistake they made. It is best to order exceptions in Catch blocks from the most specific to the least specific. In other words, the Catch block that is most likely to be needed for the most common exception should appear first in a series of Catch statements. If an exception occurs during the execution of the Try block, Visual Basic examines each Catch statement within the Try-Catch block until it finds one whose condition matches that error. If a match is found, control transfers to the first line of code in the Catch block. If no matching Catch statement is found, the search proceeds to the next Catch statement in the Try-Catch block. This process continues through the entire code block until a matching Catch block is found in the current procedure. If no match is found, an exception occurs that stops the program.

Computer Science & Information Technology

You might also like to view...

A Search box is available directly from the Start menu

Indicate whether the statement is true or false

Computer Science & Information Technology

The options on the REPORT DESIGN TOOLS tabs are used to modify a report.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology