Home
Cv Questions
Resume Example Questions
Resume Format Questions
Resume General Questions
Resume Cover Letter Questions
Government Resume Questions
Free Resume Questions
Executive Resume Questions
Resume Writing Questions
Resume Type Questions
Online Resume Questions
Resume Help Questions
Create Resume Questions
Resume Template Questions
Resume Sample Questions
Industry Specific Resume Questions
Resume How To Questions
Site Map
 
 
   
Resume in Try Catch?

Question:
I know the Resume keyword is not allowed in a try catch statement but how do I get similar functionality? What good is try catch if I can't fix the problem and continue the code from where it left off either at that line or the next. Please any help here would be greatly appreciated.


Answer:
- Try this: Private Sub Test Try CodeThatMightFail() Catch ex as Exception 'Handle the error End Try CodeToResumeExecuting() End Sub

- So in order to acomplish this task I need to put a try catch around every bit of code that might fail? I liken that to On Error resume next with an Err.Number test after every line that might error. How is this better then On Error Goto? At least with On Error Goto I can place all my error handling in one spot where I can handle expected errors or have generic error message and then have a choice of exiting (like try catch) or returning to the offending line or the following line and continuing to execute the code that remains. I don't necessarily find it to be any neater then On Error Goto either since it could potentially add many more lines of code. It may be nice if the only error handler is to provide custom messages before exiting but otherwise it would result in many nested (if possible) Try Catches with possibly duplicate code for the fixed scenario. I don't like it. There has to be a better way to do this or I may just have to stick with the old clunker. ... This is general venting please don't take it as though I am directing it at you.

- If you want to do it the way you're saying, then use On Error Goto n or On Error Resume Next. In .Net, you'll not handle exceptions the same way. If a line of code fail, what do you want to do? Execute the next line and maybe get unpredictable results? Or will you display an error message? Or correct the problem and continue the operations after?


What is Your answer?


 
Privacy Policy