MESSAGEBOX( ) Function

Example   See Also

Displays a user-defined dialog box.

Syntax

MESSAGEBOX(cMessageText [, nDialogBoxType [, cTitleBarText]])

Returns

Numeric

Arguments

cMessageText

Specifies the text that appears in the dialog box. Use a carriage return (CHR(13)) in cMessageText to move a portion of the message to the next line in the dialog box. The height and width of the dialog box is increased as necessary to contain cMessageText.

nDialogBoxType

Specifies the buttons and icons that appear in the dialog box, the default button when the dialog box is displayed, and the behavior of the dialog box.

In the following tables, the dialog box button values 0 to 5 specify the buttons that appear in the dialog box. The icon values 16, 32, 48, and 64 specify the icon that appears in the dialog box. The default values 0, 256, and 512 specify which button in the dialog box is the default button. The default button is selected when the dialog box is displayed.

Omitting nDialogBoxType is identical to specifying a value of 0 for nDialogBoxType.

Value Dialog box buttons
0 OK button only
1 OK and Cancel buttons
2 Abort, Retry, and Ignore buttons
3 Yes, No, and Cancel buttons
4 Yes and No buttons
5 Retry and Cancel buttons

Value Icon
16 Stop sign
32 Question mark
48 Exclamation point
64 Information (i) icon

Value Default button
0 First button
256 Second button
512 Third button

nDialogBoxType can be the sum of up to three values — one value from each of the preceding tables. For example, if nDialogBoxType is 290 (2+32+256), the specified dialog box has the following characteristics:

cTitleBarText

Specifies the text that appears in the title bar of the dialog box. If you omit cTitleBarText, the title "Microsoft Visual FoxPro" appears in the title bar.

Remarks

The value MESSAGEBOX( ) returns indicates which button in the dialog box was chosen. In dialog boxes with a Cancel button, pressing ESC to exit the dialog box returns the same value (2) as choosing Cancel.

Note that the shortest abbreviation for this function is MESSAGEB( ).

The following table lists the values MESSAGEBOX( ) returns for each button.

Return value Button
1 OK
2 Cancel
3 Abort
4 Retry
5 Ignore
6 Yes
7 No