Making Console application in Visual Basic

Apart from Windows applications, Visual Basic can be used to build applications that run in a command prompt window. The command prompt window isn’t really a DOS window, even though it looks like one. It’s a text window, and the only way to interact with an application is to enter lines of text and read the output generated by the application, which is displayed in this text window, one line at a time. This type of application is called a console application.

Step 1 : (Creating Project)

Build a new project from the file menu File > New > Project > ConsoleApplication1
 
Here we have selected Console Application instead of Windows Application. New Project will open named ConsoleApplication1 with the following default code :

Module Module1

    Sub Main()

    End Sub

End Module

Step 2 : (Writing Code)

write the following code in Module1.vb (opened file)

Module Module1

    Sub Main()
        Console.WriteLine("Enter message") ' writing message
        Dim message As String ' string variable message for storing input
        message = Console.ReadLine() ' reading a line
        Console.WriteLine(message) ' outputting input value

        Console.WriteLine("PRESS ENTER TO EXIT")
        Console.ReadLine() ' waiting for one character to enter from user to pause screen
    End Sub

End Module

Step 3 : (Debug)

Start Debugging your code and the output will be :