Use message box to display the messages in VB.NET
This article shows a message box that can contain text, buttons, and symbols to inform the user.
In this article we will discuss how to use message box to display the messages in windows forms in VB.NET.
Message box
Displays a message box that can contain text, buttons, and symbols to inform the user.
Message box class
Message box class are used for general message and user response.
1. general message
The simplest form of a MessageBox is a dialog with a text and OK button. The following code creates a simple MessageBox.
MessageBox.Show(string message, string caption, MessageBoxButtons b, MessageBoxIcon ic)
Example1-To display a simple message.
MessageBox.Show("Record has been updated")

Example2-To display a message with title.
MessageBox.Show("Record has been updated", "update")

Example3-Message box with caption and buttons.
MessageBoxButtons-specifies which buttons to display on a message box.
MessageBox.Show("Record has been updated", "update", MessageBoxButtons.YesNoCancel)

Example4-Message box with caption, buttons and icon.
MessageBox.Show("Record has been updated", "update", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error)


2. Query message: To get response from the user.
Dialogresult- Dialog result are used to indicate the return value of a dialog box.
The following code creates a query mesage.
Dim ans As DialogResult = MessageBox.Show("Save the record", "Save", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
If ans = DialogResult.Yes Then
MessageBox.Show("Yes clicked")
ElseIf ans = DialogResult.No Then
MessageBox.Show("No clicked")
Else
MessageBox.Show("Cancel clicked")
End If

Now click on the any button yes, no, cancel suppose we click on the yes button.
