View contents of this chapter

MsgBox() Function: Return Values


Value Constant Description
1 vbOK The user clicked OK
2 vbCancel The user clicked Cancel
3 vbAbort The user clicked Abort
4 vbRetry The user clicked Retry
5 vbIgnore The user clicked Ignore
6 vbYes The user clicked Yes
7 vbNo The user clicked No

Play Sound If the user presses Esc at the message box, VB responds as if the user clicked the cancel button.

Specifying the Icon

Adding an additional value to the second argument specifies the icon used to the left of the message inside the message box. The following table shows the named constant values and the icons they produce.

Value Constant Description
16 vbCritical Display Critical Message icon.
32 vbQuestion Display Question mark icon.
48 vbExclamation Display Warning Message icon.
64 vbInformation Display Information Message icon.

The following code segment produces a message box with an icon

intResponse = MsgBox ("Are you ready?", vbYesNo + vbQuestion, "Question Box")

Figure 9.3

The MsgBox() function actually supports a few additional and optional arguments but we won't discuss about them.



© Universal Teacher Publications        INDEX Previous Screen Next Screen