MsgBox( msg, [type] [, title] )
Value | Meaning |
---|---|
0 | Display OK button only. |
1 | Display OK and Cancel buttons. |
2 | Display Abort, Retry, and Ignore buttons. |
3 | Display Yes, No, and Cancel buttons. |
4 | Display Yes and No buttons. |
5 | Display Retry and Cancel buttons. |
16 | Stop Icon |
32 | Question Icon |
48 | Exclamation Icon |
64 | Information Icon |
0 | First button is default. |
256 | Second button is default. |
512 | Third button is default. |
768 | Fourth button is default |
0 | Application modal |
4096 | System modal |
The first group of values (1-5) describes the number and type of buttons displayed in the dialog box; the second group (16, 32, 48, 64) describes the icon style; the third group (0, 256, 512) determines which button is the default; and the fourth group (0, 4096) determines the modality of the message box. When adding numbers to create a final value for the argument type, use only one number from each group. If omitted, the default value for type is 0.
Value | Meaning |
---|---|
1 | OK button selected. |
2 | Cancel button selected. |
3 | Abort button selected. |
4 | Retry button selected. |
5 | Ignore button selected. |
6 | Yes button selected. |
7 | No button selected. |
Dim Msg, Style, Title, Help, Ctxt, Response, MyString Msg = "Do you want to continue ?" ' Define message 'Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons Style = 4 + 16 + 256 ' Define buttons. Title = "MsgBox Demonstration" ' Define title Help = "DEMO.HLP" ' Define Help file Ctxt = 1000 ' Define topic ' context. ' Display message. Response = MsgBox(Msg, Style, Title, Help, Ctxt) If Response = vbYes Then ' User chose Yes MyString = "Yes" ' Perform some action Else ' User chose No. MyString = "No" ' Perform some action End If