Learn to program in Visual Basic .NET, the right way

The Basics - Input and Output

What is Input and Output?

Simply put, input and output is the communication between the computer and the person using the application.

Many programs will require some type of human interaction, because of this Visual Basic .NET has some built in methods to handle the interaction.

Output

There are two methods of displaying values in a Console Application: Console.Write and Console.WriteLine.

The Console.Write method will print a value but keep the caret on the same line, so if another value is printed, then it will be printed on the same line.

The Console.WriteLine method will print a value and also return a new line, so if another value is printed, then it will be printed on the next line.

Examples

The following demonstrates how to use the Console.Write and Console.WriteLine methods:

Fiddle: Live Demo

Input

There is one method of reading values in a Console Application: Console.ReadLine.

The Console.ReadLine method will read a value and also return a new line, so if another value is printed or read, then it will be printed/read on/from the next line.

The Console.ReadLine method will return a String value, which in turn can be stored in a String variable.

Examples

The following demonstrates how to use the Console.ReadLine method:

Fiddle: Live Demo

Remarks

In the Console.ReadLine example, I use the & operator. This particular operator joins together two Strings.