There are several very simple ways of outputting information to the user or to the debugger. Some forms are obtrusive outputs and some are unobtrusive.
An obtrusive output means that the program stops running the main sequence whilst the output is displayed whereas an unobtrusive output does not stop the main execution.
Console outputs
The console is a form of collecting multiple outputs for reference. Output here is unobtrusive.
Console.Write
The Console.Write
method is used to output any information
of any of 17 types (for instance, boolean, integer, single) on to
a line without taking a new line.
Below is a sample write command:
Console.Write("Hello world") Console.Write("This is a test")

Console.WriteLine
The Console.WriteLine
method is used to output
some text and take a line break after it. This way multiple outputs
do not get mixed up as easily as shown above.
Console.WriteLine("Hello world") Console.WriteLine("This is a test")

Dialog based output
Dialog based output such as message boxes tends to be obtrusive output - it breaks execution of the program.
MsgBox
One of the simple forms of output is to use MsgBox
which
simply takes up to three arguements as follows:
MsgBox(prompt As String, [Buttons As MsgBoxStyle] [title As String])
The prompt parameter is used to contain a message as a string and title is an optionalMeaning it does not need to be included, instead the compiler gives it a default value. parameter. Below is a sample:
MsgBox("Hello world")

The other option that was given was the Buttons option. This option is used to specify how the message box looks. Below is a table showing all types of message box. All samples are from Windows 7.
MessageBox
The MsgBox
method is quite limited, whereas the MessageBox
class is more feature rich and customisable. One of the lacking
features of the MsgBox
method is that it does not support both
an icon and special buttons.
As MessageBox
is a more powerful class rather than a simple predefined shorthand function it
does not work the same way and provides much more features. The following sample illustates this.
MessageBox.Show("Hello world!", "Sample program", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)

Both of these dialog outputs return a DialogResult
as a result, which means using an if statement, the result can
be used to determine what events happen on each button.
Other output styles
There are other ways of outputting information such as directly putting the information on to the user interface through the use of a control such as a Label or ListBox.
- Create a program that displays the same sentence on both the console and on a dialog.