MsgBox Function Language Reference

Source: Internet
Author: User
Tags chr constant numeric

Describe

Displays a message in a dialog box, waits for the user to click the button, and returns a value indicating the button the user clicked.

Grammar

MsgBox (prompt[, buttons][, title][, HelpFile, context))

The syntax for the MSGBOX function has the following parameters:

Parameter description

Prompt a string expression displayed as a message in a dialog box. The maximum length of a prompt is approximately 1024 characters, depending on the width of the character being used. If the prompt contains more than one row, each row can be separated by a carriage return (CHR (13)), a newline character (CHR (10)), or a combination of a carriage return line feed (CHR & Chr (10)).

Buttons A numeric expression that specifies the number and type of display buttons, the icon style used, the identity of the default button, and the sum of the values for the message box style. For numeric values, see the "Settings" section. If omitted, the default value for buttons is 0.

Title The string expression displayed in the title bar of the dialog box. If you omit title, the name of the application is displayed in the title bar.

A helpfile string expression identifying the Help file that provides context-sensitive Help for a dialog box. If HelpFile is provided, the context must be provided. is not available on the 16-bit system platform.

A context numeric expression that identifies the contextual number assigned to a Help topic by the author of the Help file. If the context is already provided, HelpFile must be provided. is not available on the 16-bit system platform.

Set up

The buttons parameter can have the following values:

Constant numerical description

vbOKOnly 0 Displays only the OK button.

vbOKCancel 1 Displays the OK and Cancel buttons.

Vbabortretryignore 2 shows the discard, retry, and Ignore buttons.

vbYesNoCancel 3 Displays Yes, no, and Cancel buttons.

vbYesNo 4 shows Yes and no buttons.

Vbretrycancel 5 Displays the Retry and Cancel buttons.

vbcritical 16 Displays the critical information icon.

Vbquestion 32 displays a warning query icon.

Vbexclamation 48 displays a warning message icon.

vbinformation 64 displays an informational message icon.

VbDefaultButton1 0 The first button is the default button.

VbDefaultButton2 256 The second button is the default button.

VbDefaultButton3 512 The third button is the default button.

VbDefaultButton4 768 The fourth button is the default button.

vbApplicationModal 0 Application Mode: The user must respond to a message box in order to continue working in the current application.

Vbsystemmodal 4096 System mode: All applications are suspended until the user responds to the message box.

The first set of values (0-5) describes the type and number of buttons displayed in the dialog box; the second set of values (16, 32, 48, 64) is used to describe the style of the icon, the third set of values (0, 256, 512) is used to determine the default button, and the fourth set of values (0, 4096) determines the style of the message box. When these numbers are added to generate the buttons parameter values, only one number can be taken from each set of values.

return value

The MsgBox function has the following return value:

Constant Value button

vbOK 1 OK

Vbcancel 2 Cancel

Vbabort 3 Give up

Vbretry 4 Retry

Vbignore 5 Ignore

Vbyes 6 is

Vbno 7 No

Description

If both the HelpFile and the context are provided, the user can press the F1 key to see the help topic that corresponds to the contextual.

If the dialog box displays the Cancel button, pressing the ESC key is the same as clicking Cancel. If the dialog box contains Help buttons, there is context-sensitive Help for the dialog box. However, no values are returned until the other buttons are clicked.

The following example uses the MsgBox function to display a message box and the return value indicates which button is pressed:

Dim MyVar

MyVar = MsgBox ("Hello world!", "MsgBox example") ' MyVar contains either 1 or 2, ' depends on the pressed button.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.