Ad space (banner)
๐Ÿ”ทVB.NET Lessons
Lesson 58 / 68

Reading a value from standard input

This lesson covers reading standard input with VB.NET's Console.ReadLine, with the aim of writing programs that handle input from a user.

Console.ReadLine() receives a line typed at the keyboard. It is the first step from a program that only displays towards one that works interactively with its user.

The sample code prompts with Console.Write("Enter your name: "), receives the typed string into name with Console.ReadLine(), and uses it in a greeting. Note the difference between Write (no line break) and WriteLine.

A common early stumble is that Console.ReadLine() always returns a string. Using it as a number means converting with something like CInt(), and forgetting that is an error in the calculation.

In professional work, reading standard input is used for accepting user input in console applications and for interactive operation in simple tools.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run VB.NET directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)