A Message Box displays a dialog box and expects the user to click on a button, returning an indicator value from the clicked button.

Figure 1
The syntax is the following:
MsgBox(Message, Buttons, Title)
Where:
Message: Text that is going to be displayed on the dialog box
Buttons: See table below
Title: Message Box title
| Â CONSTANT | Â VALUE | Â DESCRIPTION |
| Â vbOKOnly | Â 0 | Â Displays the OK button |
| Â vbOKCancel | Â 1 | Â Displays OK and Cancel buttons |
| Â vbAbortRetryIgnore | Â 2 | Â Displays Abort, Retry, and Ignore buttons |
| Â vbYesNoCancel | Â 3 | Â Displays Yes, No, and Cancel buttons |
|  vbYesNo |  4 |  Displays Yes and No buttons |
|  vbRetryCancel |  5 |  Displays Retry and Cancel buttons |
| Â VbCritical | Â 16 | Â Displays Critical icon |
| Â vbQuestion | Â 32 | Â Displays Question icon |
| Â vbExclamation | Â 48 | Â Displays Exclamation icon |
| Â vbInformation | Â 64 | Â Displays Information icon |
|  vbDefaultButton1 |  0 |  Sets 1st button as default |
| Â vbDefaultButton2 | Â 256 | Â Sets 2nd button as default |
| Â vbDefaultButton3 | Â 512 | Â Sets 3rd button as default |
| Â vbDefaultButton4 | Â 768 | Â Sets 4th button as default |
| Â vbApplicationModal | Â 0 | Â Modal Application. The user must respond to the Message Box before continuing working in the application. |
| Â vbSystemModal | Â 4096 | Â Modal System. All applications are suspended until the user responds to the Message Box. |
The MsgBox function returns the following values:
| Â CONSTANT | Â VALUE | Â DESCRIPTION |
| Â vbOK | Â 1 | Â OK |
| Â vbCancel | Â 2 | Â Cancel |
| Â vbAbort | Â 3 | Â Abort |
| Â vbRetry | Â 4 | Â Retry |
| Â vbIgnore | Â 5 | Â Ignore |
| Â vbYes | Â 6 | Â Yes |
| Â vbNo | Â 7 | Â No |
For the example in Figure 1, we wrote the following code line:
MsgBox “Message Text”, vbAbortRetryIgnore + vbCritical, “Message title”
If you wish to keep the user’s answer, the function parameters must be between parentheses:
‘Question
resp = MsgBox(“Message text”, vbAbortRetryIgnore + vbCritical, “Message title”)
‘Answer
MsgBox “The user answered” & resp
Exercises:
1. Write the code for the following dialog boxes:

Figure 2

Figura 3
2. Write the code for the following dialog boxes and display on a second message the user’s answer.

Figure 4

Figure 5
