MsgBox function Language Reference

Source: Internet
Author: User

MsgBox function Language Reference

Description

The message is displayed in the dialog box. Wait for the user to click the button and return a value indicating the button clicked by the user.

Syntax

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

The syntax of the MsgBox function includes the following parameters:

Parameter description

Prompt is used as a string expression for displaying messages in the dialog box. The maximum length of a prompt is about 1024 characters, depending on the width of the character used. If the prompt contains multiple rows, you can use a combination of carriage return (Chr (13), line feed (Chr (10), or carriage return linefeed (Chr (13) between each row) & Chr (10) is used to separate rows.

The buttons numeric expression indicates the number and type of buttons to be displayed, the icon style used, the identifier of the default button, and the total value of the message box style. For values, see the "Settings" section. If this parameter is omitted, the default value of buttons is 0.

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

Helpfile string expression, used to identify the Help file that provides context-related help for the dialog box. If helpfile is provided, context must be provided. Unavailable on a 16-bit system platform.

Context numeric expression used to identify the context number specified by the creator of the Help file to a help topic. If context is provided, helpfile must be provided. Unavailable on a 16-bit system platform.

Set

The buttons parameter can have the following values:

Constant Value description

VbOKOnly 0 only displays the OK button.

VbOKCancel 1 displays the OK and cancel buttons.

VbAbortRetryIgnore 2 displays the discard, retry, and ignore buttons.

VbYesNoCancel 3 displays the "yes", "no", and "cancel" buttons.

VbYesNo 4 displays the "yes" and "no" buttons.

VbRetryCancel 5 displays the retry and cancel buttons.

VbCritical 16 displays the critical information icon.

VbQuestion 32 displays the alarm query icon.

VbExclamation 48 displays the warning message icon.

VbInformation 64 displays the 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: You must respond to the message box to continue working in the current application.

VbsystemModal 4096 system mode: All applications are suspended before the user responds to the message box.

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

Return Value

MsgBox functions return the following values:

Constant Value button

VbOK 1 OK

VbCancel 2 canceled

VbAbort 3 abandon

VbRetry 4 retry

VbIgnore 5 ignore

VbYes 6 is

VbNo 7 No

Description

If both helpfile and context are provided, you can press F1 to view the help topic corresponding to the context.

If the cancel button is displayed in the dialog box, Press ESC and click Cancel. If the dialog box contains the Help button, context-related help is provided for the dialog box. However, no value is returned before other buttons are clicked.

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

Dim MyVar

MyVar = MsgBox ("Hello World! ", 65," MsgBox example ") 'myvar contains either 1 or 2, 'depending 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.