Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use Finally to exit out of code

Status
Not open for further replies.

chapm4

IS-IT--Management
Nov 12, 2001
38
0
0
US
I am using try, catch, and finally for error checking on fileCopy. If an exception is caught, I choose okay on the message box. The code then continues to execute. I want to stop executing the code and go back to the form. How?
 
After the message box add the command "End Sub" or "End Function" that will kick you out of the routine.

Kris
[pc3]
 
After the message box add the command "Exit Sub" or "Exit Function" that will kick you out of the routine.

Kris
[pc3]
 
The "Finally" clause of a try..catch..finally construct *always* executes. It's designed to allow you to clean up any resources that you might have used, like database connections, etc.

If you want to return to the form, set a flag in the "catch" part to indicate an exception ocurred. Your code will run through the Finally clause as normal, and then you can test your flag to see if you need to redisplay your form.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top