Microsoft Visual Basic 2010 Step by Step eBook

(Tina Meador) #1

Chapter 9 Trapping Errors by Using Structured Error Handling 241



  1. Click the Check Drive button.


The error handler displays the error message “Please insert the disc in drive D!”
in a message box, as shown here. Behind the scenes, the Retries variable is also
incremented to 1.


  1. Click OK, and then click the Check Drive button again.


The Retries variable is set to 2, and the message “Please insert the disc in drive D!”
appears again.


  1. Click OK, and then click the Check Drive button a third time.


The Retries variable is incremented to 3, and the Else clause is executed. The message
“File Load feature disabled” appears, as shown here:


  1. Click OK in the message box.


The Check Drive button is disabled on the form, as shown here:
Free download pdf