Discussion Locked

vb.net try..catch..retry question

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
In VB.NET I have a class that allow the selection of a drive, if that drive is not available i.e. 'A:\' then an exception is raised in a Try..Catch Error handler. This handler generates a standard Windows message box with Retry, Ok and Cancel options. If the Retry option is selected how do I get the program to exit the Error handler and re-enter the function to see if the drive is now available and re-raise the exception if necessary?

6 replies

by rrv

For example let us say you are using FileSystemObject to check the status of drive A. You can find the exact exception it returns when there is no floppy in the drive. in the CATCH of that exception do nothing except to return to next line. or youcan loop it until a valid media is read after clicking Retry.

RV

by phil.watkins

This is the problem I am having, I don't understand the mechanism for returning to the next line or looping the function that is attempting the open on the missing media. The documentation I have purchased or found on the web does not seem to help.

by jhermiz

Im not too familiar with VB.Net...but once an exception is thrown..you cannot get out of that exception. The whole point of having an exception, for instance C++ exceptions, is to clean up code and exit normally rather than terminate the program without closing relasing all referencing and exiting out in an abnormal fashion. Usually with an exception you try {something} catch(something) {throw something} sometimes in some languages there is another clause such as finally which is executed EVERYTIME before program finish. So if an exception is raised in your program I'd say handle it with variables rather than exception classes / handling. That way you're not throwing any exception but you are setting flags and you may retry and old process without closing the whole program out.
Jon

This discussion is closed to new replies.