Lesson 37: Creating Console Applications in VB2019
Learn to build lightweight command-line applications with Visual Basic
Key Takeaway
Console applications are lightweight programs that run in a terminal window, perfect for utilities, scripts, and simple tools.
In this lesson, you'll learn how to create console applications in Visual Basic 2019. Unlike Windows Forms applications, console apps run in a command-line interface and are ideal for automation tasks, simple utilities, and learning core programming concepts.
Command-Line Interface
Run programs without graphical interface
Lightweight
Minimal resource requirements
Focus on Logic
Concentrate on programming fundamentals
Fast Execution
Quick startup and execution times
37.1 Creating a Console Application Project
To start creating a console application in Visual Basic 2019:
- Launch Visual Studio 2019
- Select "Create a new project"
- Choose "Visual Basic" as the language
- Select "Console App (.NET Framework)"
- Name your project and click "Create"

Figure 37.1: Creating a new console application project
37.2 The Console Application Code Window
After creating your project, Visual Studio opens the code window with the basic structure of a console application:

Figure 37.2: The console application code window
The main entry point for a console application is the Sub Main()
method. This is where your program starts execution.
Module Module1 Sub Main() ' Your code goes here End Sub End Module
37.3 Adding Modules
You can add additional modules to your console application to organize your code:
- Right-click on your project in Solution Explorer
- Select "Add" → "Module"
- Name your module and click "Add"

Figure 37.3: Adding a new module to your project
37.4 Console Application Examples
Let's explore some practical examples of console applications.
Example 37.1: Displaying a Message
This simple program uses InputBox to get user input and MsgBox to display it:
Module Module1 Sub Main() Dim myText As String myText = InputBox("Enter Your Text") MsgBox(myText) End Sub End Module
When you run this program, you'll first see an input dialog:

Figure 37.4: InputBox for user input
After entering text and clicking "OK", a message box displays your input:

Figure 37.5: Message box displaying user input
Example 37.2: Looping Program
This example demonstrates a looping structure using Do Until...Loop
:
Module Module1 Sub Main() Dim x As Single Do Until x > 100 x = x + 5 Loop MsgBox("The value of x is " & x) End Sub End Module
When executed, this program shows the final value of x after the loop completes:

Figure 37.6: Output of the looping program
Lesson Summary
In this lesson, you've learned the fundamentals of creating console applications in Visual Basic 2019:
Console Projects
Created new console application projects
Code Structure
Understood the role of Sub Main()
Input/Output
Used InputBox and MsgBox for interaction
Looping
Implemented Do Until loops
Console applications provide a simple way to develop and test algorithms without the complexity of a graphical interface.
Next Lesson
Continue learning console applications in Lesson 38: Console Applications Part 2.
Related Resources

Visual Basic 2019 Made Easy
Master Visual Basic 2019 with this comprehensive guide that includes detailed coverage of console application development. Learn to create efficient command-line tools and utilities.
Key Console Topics:
- Console application fundamentals
- Command-line argument handling
- Text-based user interfaces
- File input/output operations
- Practical console projects with source code

Console Applications with VB.NET
This comprehensive guide focuses specifically on building powerful console applications in VB.NET, covering everything from basic concepts to advanced techniques.
Console Coverage:
- Console I/O techniques
- Command-line argument parsing
- Console application architecture
- Real-world utility development