The figure below includes an example of a message box. Note the different features that can be customized by the programmer.
The TypeOfBox is determined by combining different groups of built-in integer constants.
TypeOfBox = ButtonType + IconType + ModalType + DefaultButton
The button type allows the programmer to specify the number and type of buttons that appear on the message box.
The icon type allows the programmer to choose between four different types of icons to display in the message box.
The modal type determines whether the user can can interact with other windows while the message box is displayed. For application modal, the user cannot interact with other windows in the same application, but can still interact with other programs. For system modal, the message box must be dismissed before any other action can take place in any application.
The default button is not shown in our text, but it allows the programmer to specify which button on the message box is the default.
When the MsgBox function is used, it returns a value. The table below lists the return values.
Here is an example of the MsgBox statement:
typeOfBox = vbOKOnly + vbInformation + vbApplicationModal
MsgBox "Enrollment recorded.", typeOfBox, "Status"
Here is an example of a MsgBox function call:
= vbOKCancel + vbExclamation + vbApplicationModal
response = MsgBox("OK to exit, Cancel to continue.", typeOfBox, "Exit")
If (response = 1) Then End ' OK button pressed