How do I get the console from closing immediatley upon opening in a Console Application program? I have all of the code written but when I run the program it pops up the console window and then immediatley exits so I am unable to read what is in the window to see if my program is operating correctly. This is the first time I've ever used a console window so I don't know where in the code I would need to put "whatever it is" I might need to put to keep the window open until closed by the user.

Recommended Answers

All 7 Replies


Also to slow things down you can use Thread.Sleep(100) to slow it down by a 1/10 of a second.

Imports System.Threading
Console.WriteLine("Sleep for 2 seconds.")

If you're running this from Visual Studio, you can set a breakpoint on your last line and the program will pause there.

Also, you could actually run the executable FROM the command-line (instead of Visual Studio or double-clicking an icon).

Good idea, thines01. Open CMD.exe and navigate to your debug or release folder and then type in the executables name.

Press Ctrl + F5. :)

--> Start without debugging..

Could wrap the whole thing in a while loop too.

Dim ex As String = ""

        While ex <> "exit"

            'your code here

            Console.WriteLine("Type exit to exit the application")
            ex = Console.ReadLine()
        End While
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.