MsgBox ( ) Function
The objective of MsgBox is to produce a pop-up message box and prompt the user to click on a command button before he /she can continues. This format is as follows:
yourMsg=MsgBox(Prompt, Style Value, Title)
The first argument, Prompt, will display the message in the message box. The Style Value will determine what type of command buttons appear on the message box, please refer Table for types of command button displayed. The Title argument will display the title of the message board.
Table Style Values
|
We can use named constant in place of integers for the second argument to make the programs more readable. In fact, VB6 will automatically shows up a list of names constant where you can select one of them.
Example: yourMsg=MsgBox( "Click OK to Proceed", 1, "Startup Menu")
and yourMsg=Msg("Click OK to Proceed". vbOkCancel,"Startup Menu")
are the same.
yourMsg is a variable that holds values that are returned by the MsgBox ( ) function. The values are determined by the type of buttons being clicked by the users. It has to be declared as Integer data type in the procedure or in the general declaration section. Table shows the values, the corresponding named constant and buttons.
Table : Return Values and Command Buttons
| Value | Named Constant | Button Clicked |
| 1 | vbOk | Ok button |
| 2 | vbCancel | Cancel button |
| 3 | vbAbort | Abort button |
| 4 | vbRetry | Retry button |
| 5 | vbIgnore | Ignore button |
| 6 | vbYes | Yes button |
| 7 | vbNo | No button |




