Home > Language Reference > User Dialog Functions > MsgBox


The MsgBox function displays a message box, waits for the user to click a button, and returns an integer indicating which button the user clicked.


Used to display information during script execution.


ret=MsgBox(<message> [, [<type>] [,<title] [,<timeout>]]]])


<message>, string, text to display in the dialog box. 

<type>, optional, integer, sum of values specifying the number and type of buttons to display, the icon style to use and the identity of the default button. If omitted, the default value is 0 (only an OK button is displayed). <type> cannot be a variable. If <type> is omitted, you must include the field separator (,). The possible values for <type> are listed below:
 <type> for buttons  Description
 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

 <type> for icons  Description
 16      Critical icon
 32  Confirmation icon
 48  Warning icon
 64  Information icon

 <type> for default button  Description
 0  First button is default
 256  Second button is default
 512  Third button is default


<title>, optional, string, text displayed in the title bar of the dialog box.

<timeout>, optional, integer. If after <timeout> seconds, the user did not click any button, the message box vanishes, and the return value is 128  (if the message box has only an OK button, the return value is 1).

Return value

ret, optional, integer, indicating which button has been clicked.
 Return value  Button clicked
 0  OK
 1  Cancel
 2  Quit
 3  Retry
 4  Ignore
 5  Yes
 6  No


<message> parameter must be a string. If you need to display an integer, use Str$ function to convert the integer into a string:
msgbox("The index is: "+str$(i))

See also



Ret = MsgBox("Hello", 65, "Title") ' Dialog box with OK and Cancel buttons, plus Information icon
MsgBox("Hello") ' Dialogbox with no title and one OK button

msg$="Message text"
title$="Dialog box title"
MsgBox(msg$, 0, title$)

Msgbox("You found " + str$(number) + " occurrences") 'As number is an integer, it must be first converted to a string
' using str$ function, and then str$(number) can be concatenated to other strings using the + operator.

MsgBox("Hello", , "Title")  ' As there is no type parameter, note the 2 commas

MsgBox("Hello", , "Title",10)  ' If no button is clicked, the dialog box disappears after 10 seconds.