On Error Resume Next In Vb6.0
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Samples Retired content We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. Visual Basic Language Reference Statements F-P Statements F-P Statements On Error Statement On Error Statement On Error Statement For Each...Next Statement For...Next Statement Function Statement Get Statement GoTo Statement If...Then...Else Statement Implements Statement Imports Statement (.NET Namespace and Type) Imports Statement (XML Namespace) Inherits Statement Interface Statement Mid Statement Module Statement Namespace Statement On Error Statement Operator Statement Option
Visual Basic 6 Code "On Error Resume Next" considered harmful By Palo Mraz, published on 21 Jan 2004 | Filed in Comments Visual Basic 6 SQL Server SQL As any seasoned VB programmer knows, the On Error Resume Next statement is used to check for errors the old (I might also say the C-style) way. When this statement is executed, any runtime error will be silently trapped and stored in the global Err object. We VB-ers typically use this construct to execute some "non-mission critical" code, where errors can be safely ignored. The canonical example I have seen many, many times, is the Form_Resize event handling procedure: Private Sub Form_Resize()
  On Error https://msdn.microsoft.com/en-us/library/5hsw66as.aspx Resume Next
  ' Resize the child controls on this form…
End Sub If this procedure did not contain the On Error Resume Next statement and a runtime error would occur, the application would be terminated with a nasty error message. (You do catch runtime errors in every event handling procedure, don't you?) In cases like this, the On Error Resume Next statement is quite handy, because it means less typing and more http://www.developerfusion.com/code/4325/on-error-resume-next-considered-harmful/ compact code. However, there are times, when this "handiness" might be very dangerous. The true danger of the On Error Resume Next statement lies in the fact that it makes it too easy to ignore the runtime errors. I have seen several cases, when ignoring runtime errors unintentionally was a recipe for disaster. Let me provide you with a real-life example taken from my own experience. Imagine a customer who had been using my application for several months and was happy with it. The application has a typical (somewhat boring:-) three-tier architecture (in the old days known as the Microsoft Windows DNA): VB6 front end; a typical forms-based application built with several 3rd party controls (GridEX, ActiveReports and AddFlow if you must know). VB6 back end; a DLL component configured to run as a COM+ application implementing the application's business logic (there is also the data access code-who writes middle-tier data access layer anyway:-). A set of T-SQL procedures for retrieving a updating the application's SQL Server 2000 database. One day the customer requested a new feature. After analyzing the request I realized that the request could be implemented just by enhancing one stored procedure. Great, I thought. I checked out the procedure from SourceSafe, fired up Query Analyzer, changed the procedure, debugged it and tested with the application on our test system. Everything went
"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 to proceed. To start viewing messages, select the forum http://www.vbforums.com/showthread.php?448401-Classic-VB-What-is-wrong-with-using-quot-On-Error-Resume-Next-quot that you want to visit from the selection below. Results 1 to 3 of 3 Thread: Classic VB - What is wrong with using "On Error Resume Next"? Tweet Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch http://www.dreamincode.net/forums/topic/45200-on-error-resume-next/ to Hybrid Mode Switch to Threaded Mode Jan 20th, 2007,04:48 PM #1 si_the_geek View Profile View Forum Posts Thread Starter Super Moderator Join Date Jul 2002 Location Bristol, UK Posts 38,318 Classic VB - What is wrong with using "On Error on error Resume Next"? If it is used properly, "On Error Resume Next" is a valid method of dealing with errors - but it is a method that needs to be used appropriately for the situation. While using it means that you don't get any 'annoying' error messages that stop your program, it can easily cause much bigger problems than that, such as: If one error happens, then the code after that point is likely to have errors too (especially if the first error occurred on error resume while doing something like setting the value of a variable). The follow-up error(s) that occur may be simple and 'safe', such as getting the wrong result displayed on screen (but not knowing it is wrong)... or they could be much more serious, such as accidentally deleting an important file, because you had an error getting the name of the file that you wanted to delete. If you have made any coding mistakes (such as putting a text value into an Integer variable) then your code wont do what it is supposed to do, and you wont know why. Not only is the problem hidden from you, but so is the location of it. If you are running within VB, you would normally get the line highlighted - but with "On Error Resume Next" you wont. In fact, you wont even know that there was an error, all you will know is that you have made some kind of mistake somewhere in that routine. If you don’t know what the problem is, or where it is, how will you fix it?What will the users of your program think if it gives them the wrong results? ..or does something nasty by mistake? They wont be happy, and they certainly wont think that you are a great programmer! As you are reading this article, you probably think that errors are a bad thing, and so hiding them is a good idea. As you get more experience you find that this is
1 of 1 New Topic/Question Reply 4 Replies - 8194 Views - Last Post: 23 August 2009 - 11:20 PM Rate Topic: #1 rookieLP New D.I.C Head Reputation: 1 Posts: 26 Joined: 01-September 07 on Error Resume next? Posted 05 March 2008 - 06:23 AM i finally almost finished my project..... thanx to all DIC coders;-) created a cybercafe/computer shop software in vb6(socket programming) learnt a lot. i'm scared while presentin my project in case it crashes.... i tried 2 fix all bugs but in case sumtin goes wrong i want it to keep goin without displayin an error. so do i have to use On Error Resume Next for every sub???? or is der some other way??? thanx This post has been edited by rookieLP: 05 March 2008 - 06:29 AM Is This A Good Question/Topic? 0 Back to top MultiQuote Quote + Reply Replies To: on Error Resume next? #2 born2c0de printf("I'm a %XR",195936478); Reputation: 186 Posts: 4,673 Joined: 26-November 04 Re: on Error Resume next? Posted 05 March 2008 - 06:43 AM Instead of suppressing the error, handle it like this: On Error Goto