MSGBOX                                                                Function

MSGBOX(prompt[, buttons[, title]])

Description

MSGBOX opens a dialog box, and waits for the user to tap on a button. The return value is an integer that indicates which button was tapped. The required parameter, prompt, is a string expression that is displayed in the body of the dialog box. The optional parameter, buttons, is a numeric or constant expression that specifies which buttons to draw, which icon to use, the identity of the default button, and the modality of the dialog box. The default value for buttons is 0, other values are obtained by adding the desired constants from table below. The optional parameter, title, is a string expression that is displayed in the title bar of the dialog box.

Some Windows CE devices do not have this function.

Table 15: Button constants

Constant

Value

Description

vbOKOnly

0

OK Button only

vbOKCancel

1

OK and Cancel buttons

vbAbortRetryIgnore

2

Abort, Retry, and Ignore buttons

vbYesNoCancel

3

Yes, No, and Cancel buttons

vbYesNo

4

Yes and No buttons

vbRetryCancel

5

Retry and Cancel buttons

vbCritical

16

Critical Message icon

vbQuestion

32

Warning Query icon

vbExclamation

48

Warning Message icon

vbInformation

64

Information Message icon

vbDefaultButton1

0

First button is default

vbDefaultButton2

256

Second button is default

vbDefaultButton3

512

Third button is default

vbDefaultButton4

768

Fourth button is default

vbApplicationModal

0

Application interface is disabled until user responds to dialog box

vbSystemModal

4096

Application and system interfaces are disabled until user responds to dialog box.

 

Table 16: MSGBOX return 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

 

Example

REM MSGBOX Example

'MSGBOX displays a modal dialog box

CONST TITLE = "MSGBOX Tour"

DIM Continue

MSGBOX("Hello World!")

MSGBOX "Brief tour of MSGBOX", 0, TITLE

Continue = MSGBOX("Continue tour?", _

       vbYesNo + vbQuestion, TITLE)

IF Continue = vbYes THEN

       Continue=MSGBOX("Short tour, huh?", _

       vbInformation + vbYesNo, TITLE)

END IF

Continue = MSGBOX("Repeat tour?", 257,TITLE)

IF Continue = vbCancel THEN

       MSGBOX("Goodbye!")

END IF

Output

Related Items

INPUTBOX