

MsgBox() function: A function in VB;
Function: Can create a pop-up window.
Purpose: Displays a message in a dialog box, waits for the user to click a button, and returns an Integer value indicating which button was clicked.
Syntax:
MsgBox(prompt[, buttons] [, title] [, helpfile, context])
Parameter Description:
The syntax of the MsgBox function has the following named parameters:
Prompt—-Required.
A string expression that is displayed as a message in the dialog box.
The maximum length of prompt is about 1024 characters, depending on the width of the characters used. If the content of prompt exceeds one line, you can separate each line using a carriage return (Chr(13)), a line feed (Chr(10)), or a combination of both (Chr(13) & Chr(10)).
Buttons—-Optional.
A numeric expression that is the sum of values specifying the number and type of buttons to display, the icon style used, what the default button is, and whether the message box requires a response. If omitted, the default value for buttons is 0 (which means only the OK button is displayed).
Title—-Optional.
A string expression displayed in the dialog box title bar. If omitted, the application name will be placed in the title bar.
Helpfile—–Optional.
A string expression identifying the help file used to provide context-sensitive help to the dialog box. If helpfile is provided, context must also be provided.
Context—-Optional.
A numeric expression that is a help context number specified by the help file author for the appropriate help topic. If context is provided, helpfile must also be provided.
Example:
Private Sub Form_click()
Msg = “Did you study VB today?”
r = MsgBox(Msg, 66, “This is the WeChat public platform to learn VB”)
End Sub
When the type value is 66, the following interface is displayed:
Private Sub Form_click()
Msg = “Did you study VB today?”
r = MsgBox(Msg, 3, “This is the WeChat public platform to learn VB”)
End Sub
When the type value is 3, the following interface is displayed:

The meaning and function of the MsgBox statement are the same as that of the MsgBox() function. Note that:
1. It does not return a value and is often used for simple information display;
2. The MsgBox statement does not require parentheses, just write:
MsgBox “Did you study VB today?”
Running will show the following image:
If you have any questions about learning VB, you can add the learning editor’s WeChat ID: vbyjk521, available for online Q&A at any time.


Long press the image above to follow the WeChat public platform to learn VB

Learn VB with Me
Official QQ Group|465615041