Using VB 2008 Express, this is not a problem but a philosophical question. Which is preferred method of providing user with error messages on forms, errorhandler or message boxes? Error handler seems like it's the direction Microsoft would like us to go in, with providing even the errror message as a property at the control level, but message boxes seem easier to use, more familiar to users perhaps and also offer more function, through more text and button options. Just curious as to thoughts from the group at large.
Thanks,
Bill P.
"If the only tool you have is a hammer, you tend to look at every prolem as a nail."

Recommended Answers

All 12 Replies

I think it depends on the application. In most cases a messagebox would be fine. However, sometimes you are several layers deep and don't want to just stop the program. But want to pass the error back up the chain. Then an error handler is the key.

I am with you Wayne. In addition, the messagebox interrupts the user, and also, it is modal.

Martin,

But the errorhandler requires the user to position the cursor over the red ! to even see what the error is, which is also extra work, plus the error message is limited by not allowing button options.

When you say modal, what are the implications?

Bill P.

A modal message box is one that need to be closed before continue working in the application. That means that you can`t access any menus, button, or any other control in the application until you close it. More information here: http://www.codinghorror.com/blog/archives/000019.html

I feel the message box is more intuitive.

You can choose the type of message box, say Critical - when the user sees this (accompanied by the critical system sound) the user knows that an error has occurred in the application.

Martin,
Excellent link regarding the modal message box. Point well taken, though neither approach is perfect. In the GREEN SCREEN (egads!) world, we show a bright eye catching message at the bottom of the screen and focus the field, which I find preferable to either the errorhandler or the message box, but then again, what does a grandfather know?
Bill P.

One more thing about modal message box.
Joel Spolsky in the chapter 1 of his book "User Interface Design for Programmers" says:

[...]A bunch of tiny frustrations, and a bunch of tiny successes. But they added up. Even something which seems like a tiny, inconsequential frustration affects your mood. Your emotions don't seem to care about the magnitude of the event, only the quality.
And I started to learn that the days when I was happiest were the days with lots of small successes and few small frustrations.[...]

Have you used VB6? Have you been writing an incomplete sentece ano moved the cursor to a line above or below? Don`t you? Just try this:

If myStrVar = "something"

... and without writing the "Then" keyword move the cursor up or down one line. VB6 will show up a screaming MessageBox telling you that there is a syntax error in that line. No more cursor move, no more writing code, no more anything until you close that MessageBox.

The application steal your focus. I repeat, the application steal your focus!!! Why don´t just mark the line in red? Not enough for you, brilliant IDE programmers? Mark the line in red and put a big red blinking icon at the end of it. But please, don´t steal my focus.

And I don't think that the sound of this MessageBox makes me feel good...

Yes, I know, you can disble this behavior in the configuration of VB6, but it comes on out the box.

As Spolsky says, a bunch of tiny frustations makes you feeel bad at the end of the day. One or two MessageBox will not hurt you. But if everytime you try to move out the cursor of an incomplete sentence the application screams and interrupts your work...

Martin,

I agree, and see your point, especially as I am a heads down typist and am a long suffering victim of exactly what you speak of, "STOLEN FOCUS." I never knew what to call it.

I might give errorhandler a try as a result, though I find it more difficult to code than MsgBox, so we will see whether my laziness wins out or not.

Bill P.

You might look at Try:Catch and Throw Exception also.

The use of Error Handler or Message Box depends on the application. Though it is recommended to use an Error Handler there are times where it might be intrusive.
With Windows XP SP2 and Windows 2003 SP1, exception handling got much more expensive, particularly when DEP is enabled. This is because of all the security hardening that was added in at the kernel level.
919490 Programs that throw many exceptions run significantly slower on a Windows XP Service Pack 2 (SP2)-based computer
http://support.microsoft.com/default.aspx?scid=kb;EN-US;919490

In such scenario a MsgBox can do the job. But, if we need to handle the error and make the application do some task Error Handler is the best way.

Sandeep,
Let me ask you a question:
For what, we as programmers, write code?

  • For the computer to process it?
  • To minimize the clock cycles of the processor?
  • To make the users of our application more productive and comfortable?

As you said, it depends on the application.

If you are writing a driver or a graphics processing application, you need speed. All the speed you can get.

But, if you are writing an application which your user must interact with all the day (like an accounting program), you must make him feel comfortable and productive. If you lose a little of speed using Error Handlers, but don't annoying the user with MessageBoxes appearing here and there, I think I can live with it.

I am talking about how my user will feel using my software, and I really don't care if I lose a 5/1000th of second. At the end, the user wont note it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.