Changing the MsgBox Buttons Captions
Posted on 1998-09-05
To detect errors in one of my programs I use an "On Error goto ErrTrap" statement in each Sub Procedure (of which there are about 500). Then I have an ErrTrap in each Sub Procedure which uses a MsgBox to direct the action to be taken.
Typically I want the user to select one of 3 options:
1 - "Continue" (Ignore the error and continue execution)
2 - "Main Menu" (close all windows and return to Main Menu)
3 - "End Program" (Stop execution of the program)
Unfortunately the standard MsgBox has certain preset MsgBox constants such as vbAbortRetryIgnore, or vbYesNoCancel which don't fit my 3 options. Is there any way to customize the Messages on the Buttons of a MsgBox to better fit my 3 options?
One possible solution is to create my own code to SIMULATE a MsgBox. I tried this by creating a form "frmErrMsg" with Message labels and 3 Command Buttons so that it looks like and behaves like a MsgBox. I works fine when I call it up from an ErrTrap. I load it modally to force the user to respond with a Button Click to deal with the error before it allows the program to resume.
However it bombs out when MULTIPLE errors occur before the original error is cleared. VB5 won't allow a form to be loaded modally more than once, if it is already loaded.
So I am forced to go back to the MsgBox once again with its inadequate buttons captions.
Any solutions to this problem?