This is for all the beginners out there that have problems with their apps making errors.
I dont care about votes it's just to help you all out, you advanced guys know this but some of the beginners wont.
Terms of Agreement:
By using this article, you agree to the following terms...
You may use
this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
You may link to this article from another website, but ONLY if it is not wrapped in a frame.
You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
'Simple, just put the below code above
any of your other codes, so if it has an error the program wont crash.
On Error Resume Next
'It cant be more simple.
Well yes I did know that. And true I'm sure a number of other people do. But I know everyone doesn't. And I'm sure it can and will help someone. However if you add:
if err then msgbox "Error: " & err.number & chr(10) & err.description, vbokonly + vbcritical, "Error: " & err.number
at the bottom of the function it will also give a messagebox explaining the error to the user. That is just an example of course and could be modified to suit your needs. :) (If this comment was disrespectful, please report it.)
If you are using in-line error handling, make sure you use Err.Clear and the end of your Error Handler or Else the Error object will still contain an error. (If this comment was disrespectful, please report it.)
Hmm. I've never had that problem before, and never have cleared the error with err.clear. Interesting though, I will have to investigate further. (If this comment was disrespectful, please report it.)
yes Andy, alot of people DO know that, but hence the beginners. It's for them if they dont know how to do it, simple. (If this comment was disrespectful, please report it.)
didnt know about the err.clear either..see everyoen can get somthign fromit ...even if it isnt in just the submission btu the discussion..but so few discussions take place *sighs* (If this comment was disrespectful, please report it.)
Hmm. My last post was cut off after an excruciating registration process. Sorry all, but I give up (and it was good, too :)) (If this comment was disrespectful, please report it.)
Sure.. this will handle errors, however, it is NOT the best way to do so. This introduces hard to find bugs in your application because the code continues to execute regardless of the errors. Your code should always look to handle the errors appropriately, while cleaning up after itself. This, too, is for beginners. DOn't want them to get into the BAD, BAD, BAD habit on On Error Resume Next (If this comment was disrespectful, please report it.)
i don't think this is the way to handle...like this errors will appear and won't be able to debug the system..besides the system could simply crash and you won't know the reason .... i think you should be used only in certain situations.... (If this comment was disrespectful, please report it.)
sorry ..i mistyped it ... " like this , Error won't appear .. and it should be used in certain situations.." (If this comment was disrespectful, please report it.)
Well, I don't think skiping errors is the best way to correct them, that's just pushing the proplem back and in the end, still you have to deal with it somewhere. I like to use an Add-in to VB that adds/removes line numbers. And every time I compile my code I add the numbers and then again remove them, when I wan't to edit the code. That way I can get the procedure name of the error and also get the line number where the error accured with Erl. (If this comment was disrespectful, please report it.)
No offense, but I can't believe this is code of the day. Bludgeoning your way through code ignoring all errors that may occur is bad practice and should be avoided by everyone (including beginners) (If this comment was disrespectful, please report it.)
Don't knock the author on this one. I am not a great VB programmer yet, still learning the ropes. Although I knew about it before coming here, I feel I need to leave a comment. Resume Next has proved very helpful, simply because my programs don't fall over! To have a program crash on you is not looked upon lightly here. I use it, along with a Select Case - Case Else (to trap any unexpected errors) to do my error trapping. It is a quick, easy to use Error handler, that works very well for beginners. I am sure, once I have advanced my knowledge of VB that it's usefullnes will end, but for now it's the easiest solution. Thanks for the submission. I wish more people would consider absolute beginners and not worry what the advanced users are going to say about their submission. (If this comment was disrespectful, please report it.)
Uhm.. guys.. there's a reason you're getting an error, whether it's list index out of bounds or something didn't work.. you need to write error handlers instead of just doing On Error Resume next. Obviously if something errored in a procedure or function then the rest of it could be scrap if an invalid value is returned or whatnot. Err.clear or whatever it is and moving on isn't the way to go. :P Look WHY it errored and fix it, don't work around it (If this comment was disrespectful, please report it.)
4/18/2003 5:05:58 AM:
Dear Sir Please send to me many aplications for visual Basic,includes form and source code and best solution for a aplication Thak you very much! Best regards Phat (If this comment was disrespectful, please report it.)
4/9/2005 1:14:23 AM:
ConnectTo "http://www.planetsourcecode.com"
Connection.Address = ?++.GoBack
//End of code (If this comment was disrespectful, please report it.)
4/9/2005 1:16:19 AM:
Me.Name = "questionPlusPlus" //sorry (If this comment was disrespectful, please report it.)
yes on error resume next is good but , its not a complete solution in coding...tell more? (If this comment was disrespectful, please report it.)
Add Your Feedback
Your feedback will be posted below and an email sent to
the author. Please remember that the author was kind enough to
share this with you, so any criticisms must be stated politely, or they
will be deleted. (For feedback not related to this particular article, please
click here instead.)