Solved

Error Handler

Posted on 2003-12-04
4
285 Views
Last Modified: 2012-05-04
Hello All,

Any ideas to why my application won't read my error handler routine? In other words, I place some bad code, but Visual Basic error code appears and I can't get it to default to my error handler. Has something changed in the VB IDE? HELP. ADawn

On Error Goto ErrorHandler

     'Somewhere in here place bad code...

Exit_ErrorHandler:
Exit Sub
 
ErrorHandler:
 
  MsgBox "I_Should_See_This_Message"   'If working, I should see this message
 
  Call PublicMessengerErrors        
  Call ErrorLogger("cmdButtons_Click")
  Resume Exit_ErrorHandler
 
End Sub
0
Comment
Question by:ADawn
4 Comments
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 50 total points
Comment Utility
Right-click anywhere in the code editor where it is blank, select Toggle, then Break in class module.
0
 

Author Comment

by:ADawn
Comment Utility
I think I found the problem. In the VB IDE there is a selection in Options: "Break On All Errors." I deselected this option (I selected: Break On Class Module) and now my code is read.

Question: Which option should be selected when I finally compile and distribute my application?

Thanks to All, ADawn.
0
 
LVL 26

Expert Comment

by:EDDYKT
Comment Utility
>>Which option should be selected when I finally compile and distribute my application

I doesn't matter, this only affect VB IDE not the compile version
0
 
LVL 4

Expert Comment

by:PBuck
Comment Utility
One more note which you may already be aware of?  But if you are calling other procedures without error handling then VB errors will appear.

So ...

Private Sub TestMe()
   On Error Goto err_Handler
   Call AnotherTest
   Exit sub

err_Handler:
   MsgBox "I see it!"
End Sub

Private Sub AnotherTest()
   Err.Raise 13
End Sub

Hope this helps
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now