On Error Retry Vb6
FORUMSFOR COMPUTER PROFESSIONALS Log In Come Join Us! Are you aComputer / IT professional?Join Tek-Tips Forums! Talk With Other Members Be Notified Of ResponsesTo Your Posts Keyword Search One-Click Access To YourFavorite Forums Automated SignaturesOn Your Posts Best Of All, It's Free! Join Us! *Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail. Posting Guidelines Promoting, selling, recruiting, coursework and thesis posting is forbidden.Tek-Tips Posting Policies Jobs Jobs from Indeed What: Where: jobs by Link To This Forum! Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.Just copy and paste the BBCode HTML Markdown MediaWiki reStructuredText code below into your site. Visual Basic(Microsoft): Version 5 & 6 Forum at Tek-Tips HomeForumsProgrammersLanguagesVisual Basic(Microsoft): Version 5 & 6 Forum On Error RETRY thread222-210266 Forum Search FAQs Links MVPs On Error RETRY On Error RETRY pascalxricher (Programmer) (OP) 12 Feb 02 08:18 Hi!Is it possible to do a Retry on the line that caused the error in an error handling ? RE: On Error RETRY dsi (Programmer) 12 Feb 02 09:20 Just use the GoTo statement. You must be sure to handle the potential endless loop. Here is some rough code to show you how to use the GoTo statement. I am not going to get into the whole "use of goto" issue.Sub SomeSub()Dim i As IntegerOn Error Goto ErrHndlr'some code hereOn Error Goto RetryRetry:Err.Cleari = i + 1If i = 10 GoTo CutItOut'Code You Want To RetryCutItOut:Err.ClearOn Error Goto ErrHndlr'Remainder of CodeEnd SubHope this helps... RE: On Error RETRY Foada (Programmer) 12 Feb 02 09:30 Yes it isSub MyError()...On Error Goto ErrHndli = 100/y' Error if y = 0...ErrHndl:Select Case Err.NumberCase 11 'Division by 0 Errormsgbox " Cannot Divide By Zero",vbInformation,"Error"Exit SubCase ElseResumeEnd SelectEnd SubIf the error is a divide by zero error the sub will exit other wise it will return to the line that created the error. You need to make sure you handle the error when you do this otherwise you could end up with a infinite loop and a program lock up Anything is possible, the problem is I only have one lifetime. RE: On Error RETRY WilMead (IS/IT--Management) 12 Feb 02 10:51 You can even change the on error state.HandleError:Dim ErrorCountErrorCount = ErrorCount + 1If 3 < ErrorCount thenON error GOTO FailErrorendif'... Adjust to attempt error resolution ...ResumeFailError:
of losing unsaved data. If it's not her lucky day, her computer jams and the database corrupts. The system won't start up again. There is no backup. Naturally, she calls you (or your boss) yelling and demanding immediate action. You don't even know the error message. You get sick of such a user and never want to deal with her again. Tired of problems, you quit your developer career and start making burgers instead. Benefit from errors There's nothing positive about errors, is there? How about this way to look at it: When an error hits the user, your application reacts to it in a reasonable way, protecting the data and http://www.tek-tips.com/viewthread.cfm?qid=210266 reporting the error to you. You find the cause of the fault and provide a fix in a short time. The user is amazed by your performance and buys a new project from you. You're the best choice since not only is your software great but you also give the best service. This kind of a paradise is not so far from the reality. With proper error handling you protect the users and get http://www.aivosto.com/vbtips/errorhandling.html extensive information for fixing the bugs. This article is written with Visual Basic 6.0 in mind. The concepts presented are universal and not tied to a specific language or environment. VB Watch Protector is an automated tool that provides VB applications with the error handling features suggested by this article. What should your app do when an error occurs? When a run-time error occurs, the default way for Visual Basic to handle it is to display an error message and crash. Would you design your apps this way? Instead of the default way, you should trap the error, display a detailed description of what happened and give the user some options to cope with the failure. Retry the operation. If you can't overwrite a file because it's read-only, the user can possibly fix this herself and retry it. Ignore the error and try to continue execution. This is often a practical solution, provided that the code copes with the incompletely executed statement. Always ignore this error. This option is very handy if the same error keeps coming up repeatedly. This could happen if the error occurs in a loop or a recurring event, such as a form's Paint event or a Timer event. Without the option to Always ignore an error, the only way to survive is to quit
with On Error Resume Next If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above http://www.vbforums.com/showthread.php?679371-RESOLVED-How-to-handle-errors-with-On-Error-Resume-Next to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Results 1 to 11 of 11 Thread: [RESOLVED] How to handle errors with On Error Resume Next Tweet Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode May 11th, 2012,01:11 PM #1 aab1 View Profile View Forum Posts Thread Starter Addicted Member Join Date on error Nov 2010 Posts 160 [RESOLVED] How to handle errors with On Error Resume Next My program uses Inet to connect to the internet, every now and then there's a timeout error which I handle but sometimes the program still manages to crash with a timeout error that for some reason wasn't handled. This is a server application that absolutely cannot ever crash for absolutely any reason whatsoever. I used to simply have On Error on error retry resume next and it would simply ignore all errors, this did make it uncrashable but I wanted to implement a 5 retry feature so that it doesn't just give up on timeout errors. I'm considering going back to on error resume next but need to know how to handle the timeout errors properly, would it be simply like this: On Error Resume Next RetryCnt = 0 Inet.OpenURL ... If Err.Number =