MsgBox Statement

Displays a message in a dialog box and waits for the operator to choose a button.

Syntax
MsgBox message$ [, type] [, title$] [, answer]

Parameters

message$
The message that will be displayed
type
Specify a number or expression representing the sum of the number and type of buttons to be displayed, the icon style, and the button heading.
The first group of values (0 to 5) indicates the number and type of buttons.
The second group (16, 32, 48, 64) indicates the icon style.
The third group (0, 256, 512) determines the default button. Select only one value from each group and add them together to form the value of the Button Type argument.
Epson RC+ includes predefined constants that can be used for this parameter.

  • Quantity and type

    Symbolic constant Value Meaning
    MB_OK 0 Display OK button only.
    MB_OKCANCEL 1 Display OK and cancel buttons.
    MB_ABORTRETRYIGNORE 2 Display Abort, Retry, and Ignore buttons.
    MB_YESNOCANCEL 3 Display Yes, No, and Cancel buttons.
    MB_YESNO 4 Display Yes and No buttons.
    MB_RETRYCANCEL 5 Display Retry and Cancel buttons.
  • Style of icon

    Symbolic constant Value Meaning
    MB_ICONSTOP 16 Stop sign.
    MB_ICONQUESTION 32 Question mark.
    MB_ICONEXCLAMATION 48 Exclamation mark.
    MB_ICONINFORMATION 64 “i” mark.
  • default

    Symbolic constant Value Meaning
    MB_DEFBUTTON1 0 First button is default.
    MB_DEFBUTTON2 256 Second button is default.
    MB_DEFBUTTON3 512 Third button is default.
title$
Optional. String expression that is displayed in the title bar of the message box.
answer
Specify a variable that accepts a value (integer) representing the user's choice. Epson RC+ includes predefined constants that can be used for this parameter. The table below shows the values returned in answer.
Symbolic constant Value Meaning
IDOK 1 OK button selected.
IDCANCEL 2 Cancel button selected.
IDABORT 3 Abort button selected.
IDRETRY 4 Retry button selected.
IDIGNORE 5 [Ignore] button selected.
IDYES 6 Yes button selected.
IDNO 7 No button selected.

Description
MsgBox automatically formats the message. If you want blank lines, use CRLF in the message. See the example.

See Also
InputBox

MsgBox Statement Example
This example displays a message box that asks the operator if he/she wants to continue or not. The message box will display two buttons: Yes and No. A question mark icon will also be displayed. After MsgBox returns (after the operator clicks a button), then the answer is examined. If it's no, then all tasks are stopped with the Quit command.

Function msgtest
  String msg$, title$
  Integer mFlags, answer

  msg$ = Chr$(34) + "Operation complete" + Chr$(34) + CRLF
  msg$ = msg$ + "Ready to continue?"
  title$ = "Sample Application"
  mFlags = MB_YESNO + MB_ICONQUESTION
  MsgBox msg$, mFlags, title$, answer
  If answer = IDNO then
    Quit All
  EndIf
Fend

A picture of the message box that this code will create is shown below.

Restriction
If the message$ and title$ of parameter contain a half-width comma ",", the string cannot be displayed correctly. Use a string that does not contain a half-width comma.