ID : 5123
MsgBox
Function
Displays a message in a dialogue box, and returns value of clicked button.
Syntax
MsgBox(message[, button[, title]])
Guaranteed Entry
- Message
- Specifies a message by string type data.
- Button
-
Specifies a button and an icon by integer type data.
In order to specify a button and an icon at the same time, write as (value of button)+(value of icon). -
Value Description 0 [OK] 1 [OK] [Cancel] 2 [Abort] [Retry] [Ignore] 3 [Yes] [No] [Cancel] 4 [Yes] [No] 5 [Retry] [Cancel] Value Description 16 Critical Message icon. 32 Warning Query icon. 48 Warning Message icon. 64 Information Message icon. - Title
- Specifies a title bar of a dialogue box by string type data.
Return Value
Returns clicked button number by integer type data.
Value | Selected button |
---|---|
1 | [OK] |
2 | [Cancel] |
3 | [Abort] |
4 | [Retry] |
5 | [Ignore] |
6 | [Yes] |
7 | [No] |
Description
Displays a message in a dialog box, waits for the user to click a button, and returns a number of button that the user clicked.
Related Terms
-
Attention
- If a teach pendant is not connected, error is issued when the command is executed.
- If more than 10 dialogue boxes are opened simultaneously in a whole task, a task that opens the eleventh dialogue box or later will cause errors.
- If the MsgBox is performed in WINCAPSIII or EMU, program goes in endless wait.
This is because a dialog box of MsgBox is not displayed in the simulation of WINCAPSIII or EMU.
To avoid this, execute a conditional branching as shown below with SIMULATION macro.
#If Not __SIMULATION__
I0 = MsgBox("...")
#EndIf
Example
Sub Main
I0 = MsgBox( "Do you want to execute?", 1+32, "Processing confirmation" )
'1([OK][Cancel]button) + 32(Warning Query icon)
Select Case I0
Case 1 '[OK]
' ...
Case 2 '[Cancel]
' ...
End Select
End Sub
ID : 5123