A message box is a special dialog box used to display a
piece of information to the user. As opposed to a regular form, the user
cannot type anything in the dialog box. The .NET Framework inherently
supports message boxes through its own MessageBox class. Besides
this, you can also use functions from either the Visual Basic or the Win32
libraries.

The Return Value of a Message Box

Besides displaying a message,
a message box is may be meant to let the user make a decision by clicking a
button and, depending on the button the user would have clicked, the message
box would return a value. The value returned by a message box corresponds to
the particular button the user would have clicked (on the message box). The
return values are defined in the DialogResult enumeration. The
buttons and the returned values are as follows:

If the User Clicks

The Method Returns

DialogResult.Abort

DialogResult.Cancel

DialogResult.Ignore

DialogResult.No

DialogResult.OK

DialogResult.Retry

DialogResult.Yes

The Message of a Message Box

The .NET Framework provides the MessageBox class
function used to easily create a message box. To display a simple message
with just an OK button, you can call the Show() static method of this
class. Its syntax is as follows:

public static DialogResult MessageBox.Show(string message);

In this case, the message to display must be passed as a
string to the Show() method. Here is an example:

The message to display can be made of up to 1024
characters. To display the message on multiple lines, you can use the new
line escape sequence anywhere inside the string.

The Caption of a Message Box

In reality, the MessagBox.Show() method is
overloaded with various versions. Another version is:

public static DialogResult Show(string text, string caption);

This version allows you to specify a custom caption for
the message box. With this version, the first argument is the string that
the user will see displaying on the message box. You can pass it as a
string. You can also create it from other pieces of strings.

The second argument, caption, will be the
sentence to display in the title bar of the message box. Here is an example:

When a message box is configured to display more than
one button, the operating system is set to decide which button is the
default. The default button has a thick border that sets it apart from the
other button(s). If the user presses Enter, the message box would behave as
if the user had clicked the default button. If the message box has more than
one button, you can decide what button would be the default. To specify the
default button, the MessageBox.Show() method provides the following
version: