Sep 28, 2012 Visual basic console application. Ask Question 3. I'm making a console app for Computer Science that displays a message if two numbers are the same, and a different message if they're different. Here's my code so far. Jun 20, 2013 This is what I was looking for. I noticed that I see this exact sentence whenever I'm in Visual Studio ('Press any key to continue.' I'm developing a C# Console app, but can't figure out why it only seems to work in CTRL+F5 mode. Either way, this is the functionality I'd like to appear in the final product. Friday, November 6, 2015 4:32.
I have an VB.Net Console Application running and I do not want it to close when the user hit the ENTER button, rather I want it to close when they type EXIT
and then press ENTER. What should I do?
Visual Basic Console Commands
1 Answer
Read from the console using Console.ReadLine() (which requires a carriage return to complete).
Another way to phrase it:
Remember that once you return from your Main
method, your console application closes. It's hard to advise you exactly what to do without seeing the logical structure of your application, but remember: if you want to prevent your application from exiting, don't let your Main
method return.
Not the answer you're looking for? Browse other questions tagged vb.netconsole or ask your own question.
In Visual Basic 2017, you can build console application besides Windows Form Applications. To start creating a console application, start Visual Basic 2017 and choose Console Application in the new project window, as shown in Figure 37.1 below:
Retain the name as ConsoleApp or change it to the name of your choice.
Now, click on Console Application to bring up the code window, as shown in Figure 37.2 below:
The console code window comprises modules, where the main module is module 1. You an add other modules by clicking on Project on the menu bar and click Add Module, as shown in Figure 37.3 below:
To start writing code for the console application, type your code in between Sub Main() and End Sub, as shown below:
Example 37.1: Displaying a Message
The following program will display a message ' Welcome to Visual Basic 2017 Console Programming'.
The function to display a message box is MsgBox(). Enter the code as follows:
Run the program and the output is as shown in Figure 37.5 below:
Example 37.2: A Looping Program
The function to display a message box is MsgBox(). Enter the code as follows:
Run the program and the output is as shown in Figure 37.5 below:
Example 37.2: A Looping Program
You can write a looping program using the Do Until....Loop structure, as shown below:
Visual Studio Console App
The output is