Message Box Constants

Except for vbMsgBoxHelpButton, any one of the following constants can be used with the buttons parameters of the MsgBox function to determine which buttons appear in the dialog. The vbMsgBoxHelpButton constant can be logically ORed with the button constant to add a Help button to provide context-sensitive help; this, however, also requires that arguments be supplied to the function’s helpfile and context parameters.

Constant

Value

Description

vbAbortRetryIgnore

2

Abort, Retry, and Ignore buttons

vbMsgBoxHelpButton

16384

Help button

vbOKCancel

1

OK and Cancel buttons

vbOKOnly

0

OK button; this is the default value.

vbRetryCancel

5

Retry and Cancel buttons

vbYesNo

4

Yes and No buttons

vbYesNoCancel

3

Yes, No, and Cancel buttons

You can determine which of these buttons is the default (that is, it appears selected and will be chosen if the user presses the Enter key) by logically ORing any one of the following constants with any other constants passed to the buttons parameter. The selected button is designated by its position on the dialog. By default, the first button appears selected.

Constant

Value

Description

vbDefaultButton1

0

First button is the default

vbDefaultButton2

256

Second button is the default

vbDefaultButton3

512

Third button is the default

vbDefaultButton4

768

Fourth (Help) button is the default

The MsgBox function also allows you to designate an icon that appears in the message box to ...

Get VBScript in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.