FANDOM


Getting startedEdit

To show messages in C#, you need to include this line at the top of the source file

using System.Windows.Forms;

MessageBox.ShowEdit

A simple message box would be like this:

MessageBox.Show("Hello world!");

The simple syntax of MessageBox.Show is as shows (only text is required)
DialogResult MessageBox.Show( string text, string title, MessageBoxButtons buttons, MessageBoxIcon icon )

ExamplesEdit

Yes or No?

DialogResult msgResult;
msgResult = MessageBox.Show("Yes or No?", "Yes/No", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (msgResult == DialogResult.Yes)
{
   MessageBox.Show("You chose yes");
}
else
{
   MessageBox.Show("You chose no");
}

ArgumentsEdit

textEdit

string. The message show in the box.Edit

How to add message box in vb.net


titleEdit

string. The caption of the window.

buttonsEdit

MessageBoxButtons. The buttons of the box.

iconEdit

MessageBoxIcon. The icon show on the side. (eg. Exclamation, Critical stop)