Getting started[]
To show messages in C#, you need to include this line at the top of the source file
using System.Windows.Forms;
MessageBox.Show[]
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 )
Examples[]
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"); }
Arguments[]
text[]
string. The message show in the box.[]
How to add message box in vb.net
title[]
string. The caption of the window.
buttons[]
MessageBoxButtons. The buttons of the box.
icon[]
MessageBoxIcon. The icon show on the side. (eg. Exclamation, Critical stop)