MsgBox Procedure

Displays a message with several buttons and an icon in a modal dialog box, waits for the user to click a button, and returns a number indicating which button the user clicked.

Syntax

[ lBoxId = ] MsgBox ( sMessage [, enType] [, sTitle], [sButtonsLabel] )

Note: The last optional parameter, sButtonLabel is only available in version 5 or newer.

The MsgBox procedure syntax has the following parts:
 

Name

Type

Description

lBoxId

enumAMsgBoxId

Return value indicating the button pressed.

sMessage

Val BString

String expression displayed as the message in the dialog box.

enType

Val enumAMsgBoxType

A combination of constants as specified below indicating the buttons and the icon that the message box dialog displays. If no argument is specified aMsgIconExclamation or aMsgOk is used, displaying the "OK" button message box.

sTitle

 

Val BString

 

String expression displayed in the title bar of the dialog box. If you omit sTitle, the application name is placed in the title bar.

sButtonLabel

Val BString

Optional string that can override default button's label - only available in ATEasy 5. If more than one button, each label has to be delimited by "\r\n" - see example below.

Where

enumAMsgBoxId can be one of the following:
 

Name

Value

Description

aIdOk

1

OK

aIdCancel

2

Cancel

aIdAbort

3

Abort

aIdRetry

4

Retry

aIdIgnore

5

Ignore

aIdYes

6

Yes

aIdNo

7

No

aIdClose

8

Close

aidPause

10

Pause

enumAMsgBoxType can be one of the following:
 

Name

Value

Description

aMsgOk

0*

Display OK button only.

aMsgOkCancel

1

Display OK and Cancel buttons.

aMsgAbortRetryIgnore

2

Display Abort, Retry, and Ignore buttons.

aMsgYesNoCancel

3

Display Yes, No, and Cancel buttons.

aMsgYesNo

4

Display Yes and No buttons.

aMsgRetryCancel

5

Display Retry and Cancel buttons.

aMsgAbort

6

Abort

aMsgAbortPause

7

Abort, Pause

aMsgAbortIgnorePause

8

Abort, Ignore, Pause

aMsgAbortRetryIgnorePause

9

Abort, Retry, Ignore, Pause

aMsgClose

10

Close

Combined with one of the following Message-Box Icons constants:
 

Name

Value

Description

aMsgIconHand

0x10

Stop(X) sign icon

aMsgIconQuestion

0x20

Question icon

aMsgIconExclamation

0x30*

Exclamation (warning) icon

aMsgIconAsterisk

0x40

Asterisk (information) icon

aMsgIconNoDefault

0x50

No Default icon

Combined with the following constants (Version 5 or newer):

Name

Value

Description

aMsgSystemModal

0x1000

System modal, Same as aMsgTaskModal, however, window will show on top of all other applications windows

aMsgTaskModal

0x2000

Task modal,  user must close this window before attending any other window that belong to this application. This is the default behavior of MsgBox.

Comments

If the dialog box displays a Cancel button or has a single button, pressing the ESC key has the same effect as clicking Cancel or the single button.

If sMessage consists of more than one line, you can separate the lines using a carriage return character (Chr(13)), a line feed character (Chr(10)), or carriage return – line feed character combination (Chr(13) & Chr(10)) between each line.

When the message box is displayed its parent window is disabled until the user clicks on one of the buttons and closes the message box. The parent window is determined by ATEasy by using the Form internal variable as a parent. If the function is not called from within a form, ATEasy will use the current active top-level window as a parent that belongs to the same thread.

Example

The following example displays the prompt "Do you wish to delete zeros in the data prior to averaging?" in a "Yes,No,Cancel" dialog box with an question icon:

lAnswerDeleteZero = MsgBox("Do you wish to delete zeros in the data prior to averaging?", aMsgYesNoCancel or aMsgIconQuestion, "Delete zeros before averaging")

The following example displays message 's' with button labels: "Abort", "Run Test Again", "Continue", and "Pause" instead of "Abort", "Retry", "Ignore", and "Pause" (ATEasy 5 only) :

enBoxId=MsgBox(s, aMsgAbortRetryIgnorePause, "TestExec", "Abort\r\nRun Test Again\r\nContinue\r\nPause")

See Also

InputBox, MsgBeep