System Console question

  • Thread starter Thread starter Rob
  • Start date Start date
R

Rob

When issuing...

System.Console.Write and WriteLine commands... the program shells out to
Command prompt, displays message, and closes... there is no time to view
what is shown,,, how can you keep the console up in order to view the
contents ?

Thanks
 
Rob said:
When issuing...

System.Console.Write and WriteLine commands... the program shells out to
Command prompt, displays message, and closes... there is no time to view
what is shown,,, how can you keep the console up in order to view the
contents ?

Put Console.ReadLine() at the end of your program. This will make the
console window wait for an <Enter> before closing.
 
Rob said:
System.Console.Write and WriteLine commands... the program shells out to
Command prompt, displays message, and closes... there is no time to view
what is shown,,, how can you keep the console up in order to view the
contents ?

This behavior is by design. Typically console applications are launched
from a console window, for example in a "cmd" console. After execution of
the program is finished the console returns to the command prompt.

I agree with you that this makes debugging of console applications from
within the IDE complicated. You can overcome this issue by addign the
following code to the end of your 'Sub Main':

\\\
#If DEBUG Then
Console.Read()
#End If
///
 
I wouldn't bother using the DEBUG directive like in Herfried's example
because it isn't needed at all. Just do the 'Console.ReadLine()' like the
other user suggested.

Crouchie1998
BA (HONS) MCP MCSE
 
Crouchie1998 said:
I wouldn't bother using the DEBUG directive like in Herfried's example
because it isn't needed at all. Just do the 'Console.ReadLine()' like the
other user suggested.

IIRC this will prevent the application from exiting automatically when it is
being launched within a command window.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top