The MsgBox function is used in Visual Basic to display a dialog box to the user, wait for a button to be clicked and return the result to the caller. Use this question for using MsgBox specifically; for the .NET MessageBox class, use the "messagebox" tag instead.
Summary
The MsgBox function is exclusive to the Visual Basic programming language. It is commonly used in vb6, vbscript or Visual Basic for Applications (vba), but can also be used in Visual Basic .NET for backwards compatibility. (However, in vb.net, it is recommended to use the MessageBox class from the .NET Framework instead.)
Function signature
As listed on MSDN:
Public Function MsgBox( _
ByVal Prompt As Object, _
Optional ByVal Buttons As MsgBoxStyle = MsgBoxStyle.OKOnly, _
Optional ByVal Title As Object = Nothing _
) As MsgBoxResult
Prompt
is used to set the text you want to display in the dialog box.Buttons
is used to set which buttons are displayed in the dialog box. If omitted, only the OK button is shown by default.Title
is used to set the title text for the dialog box. If omitted, the application name is displayed by default.
The return value is a numeric value indicating what action the user took in response to the dialog (i.e., which presented button was clicked).