Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What is the meaning of MsgBox function parameters in VB?
What is the meaning of MsgBox function parameters in VB?
MsgBox function

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

MsgBox (prompt [,button [,title] [,help file, context])

parameter

point out

A string expression displayed as a message in a dialog box. The maximum length of the prompt is about 1024 characters, depending on the width of the characters used. If the prompt contains multiple lines, you can use carriage return (Chr( 13)), line feed (Chr( 10)) or the combination of carriage return and line feed (chr (13)&; Chr( 10)).

Small Attendant

Numerical expression is the sum of numerical values, indicating the number and type of specified display buttons, the icon style used, the identification of default buttons and the message box style. For numerical values, see the Settings section. If omitted, the default value of the button is 0.

title

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

Help file

A string expression that identifies the help file that provides context-sensitive help for the dialog box. If a help file has been provided, a context must be provided. Not available on 16-bit system platform.

context

A numeric expression that identifies the context number assigned to the help topic by the author of the help file. If a context has been provided, a help file must be provided. Not available on 16-bit system platform.

build

Button parameters 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 Give Up, Retry and Ignore buttons.

Vyesno Cancel 3 displays the Yes, no and Cancel buttons.

Vyesno4 displays "Yes" and "No" buttons.

VbRetryCancel 5 displays retry and cancel buttons.

VbCritical 16 displays key information icons.

VbQuestion 32 displays the warning query icon.

The VB exclamation mark 48 displays the warning message icon.

VbInformation 64 displays the information message icon.

The first button of vbDefaultButton 1 0 is the default button.

The second button of vbDefaultButton2 256 is the default button.

The third button of VbDefaultButton3 5 12 is the default button.

The fourth button of vbDefaultButton4 768 is the default button.

VbApplicationModal 0 application mode: users 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 set of values (0-5) is used to describe the type and quantity of buttons displayed in the dialog box; The second set of values (16, 32, 48, 64) are used to describe the style of the icon; The third set of values (0,256,512) is used to determine the default button; The fourth set of values (0,4096) determines the style of the message box. When these numbers are added together to generate button parameter values, there can only be one number in each group of values.

Return value

The MsgBox function has the following return values:

Constant value button

VbOK 1 OK

VbCancel 2 cancel

VbAbort 3 give up

Vbtry 4 retry

VbIgnore 5 ignore

Weiss 6 is

No.7

explain

If both the help file and the context are provided, the user can press F 1 to view the help topic corresponding to the context.

If the dialog box displays the Cancel button, pressing the ESC key has the same effect as clicking Cancel. If the dialog box contains a help button, the dialog box has context-sensitive help. However, no value will be returned until the other buttons are clicked.

When MicroSoft Internet Explorer uses the MsgBox function, the title of any dialog box always contains "VBScript" to distinguish it from the standard dialog box.

The following example demonstrates the use of the MsgBox function:

Dim MyVar

MyVar = MsgBox ("Hello World!" , 65, "MsgBox example")

MyVar contains 1 or 2, depending on which button is clicked.