Opens a dialog box that displays a message and pushbuttons, and returns a numeric value that corresponds to the pushbutton the user chooses.

Syntax

MSGBOX(<message expC>, [<title expC>, [<box type expN>]])

<message expC>

The message to display in the dialog box.

<title expC>

The title to display in the title bar of the dialog box.

<box type expN>

A numeric value that determines which icon (if any) and which pushbuttons to display in the dialog box. To specify a dialog box with pushbuttons and no icon, use the following numbers:

<box type expN>

Pushbuttons

0

OK

1

OK, Cancel

2

Abort, Retry, Ignore

3

Yes, No, Cancel

4

Yes, No

5

Retry, Cancel

To specify a dialog box with pushbuttons and an icon, add any of the following numbers to <box type expN>:

Number to add

Icon displayed


16

image\BOXICO01.gif

 


32

image\BOXICO02.gif

 


48

image\BOXICO03.gif

 


64

image\BOXICO04.gif

 

When a dialog box has more than one pushbutton, the left most pushbutton is normally the default, However, if you add 256 to <box type expN>, the second pushbutton is the default, and if you add 512 to <box type expN>, the third pushbutton is the default.

If you omit <box type expN>, box type 0—one with just the title, message, and an OK button—is used by default.

Note

If you specify <box type expN>, make sure it’s a valid combination of the choices outlined above. An invalid number may result in a dialog box that you cannot close.

Description

Use MSGBOX( ) to prompt the user to make a choice or acknowledge a message by clicking a pushbutton in a modal dialog box.

While the dialog box is open, program execution stops and the user cannot give focus to another window. When the user chooses a pushbutton, the dialog box disappears, program execution resumes, and MSGBOX( ) returns a numeric value that indicates which pushbutton was chosen.

Pushbutton

Return value

OK

1

Cancel

2

Abort

3

Retry

4

Ignore

5

Yes

6

No

7