ShowMessageBox
- Last UpdatedOct 29, 2026
- 2 minute read
ShowMessageBox is a built-in function that shows a message box with one or more buttons to capture the user's response.
|
Function |
Group |
Execution |
String Exp. |
Windows |
Windows Embedded |
IoT View |
Thin Clients |
Mobile Access |
|---|---|---|---|---|---|---|---|---|
|
ShowMessageBox |
Screen |
Synchronous |
No |
Supported |
Supported |
Supported |
Supported |
Supported |
Syntax
ShowMessageBox(strMessage, optNumButtons, optStrTitle)
strMessage
The message body that will be displayed in the box.
optNumButtons
A numeric flag that specifies which set of buttons to display in the message box:
|
Value |
Description |
|---|---|
|
0 |
OK button (default) |
|
1 |
OK / Cancel buttons |
|
2 |
Abort / Retry / Ignore buttons |
|
3 |
Yes / No / Cancel buttons |
|
4 |
Yes / No buttons |
|
5 |
Retry / Cancel buttons |
To add an exclamation icon to the box โ that is, to make it an alert or warning rather than a plain message โ add 48 (vbExclamation) to this parameter. For more information, see "Examples" below.
This parameter is optional; if no value is specified, the default value is 0.
optStrTitle
The text that is displayed in the title bar of the message box.
This parameter is optional; if no value is specified, no title is displayed.
Return value
This function returns one of the following possible values:
|
Value |
Description |
|---|---|
|
-1 |
Bad parameter. |
|
0 |
Message box not displayed because the Viewer is not open; see Notes below. |
|
1 |
User clicked OK. |
|
2 |
User clicked Cancel, or the execution was canceled by some other action; see Notes below. |
|
3 |
User clicked Abort. |
|
4 |
User clicked Retry. |
|
5 |
User clicked Ignore. |
|
6 |
User clicked Yes. |
|
7 |
User clicked No. |
Notes
Unlike other Screen functions, this function can be called from VBScript Global Procedures and VBScript scripts (script groups), and when it is, the message box is displayed in the Viewer module on the project runtime server. If the Viewer module is not open โ that is, if the Viewer task is not running โ then the message box cannot be displayed and the function returns 0.
When this function is used in project screens on Mobile Access, it has been enhanced to duplicate the functionality of the VBScript function MsgBox. Also, if the page is refreshed or reloaded while the message box is displayed, before the user has clicked any button, then the execution is canceled and the function returns 2.
The message, button labels, and title (if any) can all be displayed in other languages during project run time. For more information, see Project Localization.
Examples
Display a plain message with an OK button:
ShowMessageBox("The action could not be completed.")
Display a question with Yes / No buttons:
ShowMessageBox("Continue with action?", 4)
Display an alert with an OK button and a title:
ShowMessageBox("The action could not be completed.", 0+48, "Alert")