CONSOLE: how to do "Press Any Key To Continue"

  • Thread starter Thread starter Paul Johnston
  • Start date Start date
P

Paul Johnston

I'm using VB.Net. I've tried using Console.Read() but it requires a
line-terminator before it finishes (doesn't that mean it's functionally
equivalent to ReadLine() -- why have it then?). I've tried
Console.In.ReadBlock(), too, with no success.

So, along these lines, how would I implement, simply, a "Press Any Key to
Continue" routine or, more complex, a text menu in a Console app to get a
single character?

i.e.
1. Declare your hate for VB.Net
2. Declare your love for VB.Net
X. No Comment
Enter Your Choice [1,2,X]:

Thanks, folks.
 
Paul Johnston said:
I'm using VB.Net. I've tried using Console.Read() but it requires a
line-terminator before it finishes (doesn't that mean it's functionally
equivalent to ReadLine() -- why have it then?). I've tried
Console.In.ReadBlock(), too, with no success.

So, along these lines, how would I implement, simply, a "Press Any Key to
Continue" routine or, more complex, a text menu in a Console app to get a
single character?

i.e.
1. Declare your hate for VB.Net
2. Declare your love for VB.Net
X. No Comment
Enter Your Choice [1,2,X]:

Console.In.ReadBlock(...) might be what you're looking for.
 
I'm using VB.Net. I've tried using Console.Read() but it requires a
line-terminator before it finishes (doesn't that mean it's functionally
equivalent to ReadLine() -- why have it then?). I've tried
Console.In.ReadBlock(), too, with no success.

So, along these lines, how would I implement, simply, a "Press Any Key to
Continue" routine or, more complex, a text menu in a Console app to get a
single character?

i.e.
1. Declare your hate for VB.Net
2. Declare your love for VB.Net
X. No Comment
Enter Your Choice [1,2,X]:

Thanks, folks.
You might need to wait until Whidbey is out - see these articles on
additional console-mode support in Whidbey (next version of Visual
Studio):

"Console Support In Whidbey
Whidbey is adding support for the full range of Console features
provided by Win32, such as manipulating the full console window,
applying colors, and reading directly from keyboard.
........
Keyboard input is accessed via the KeyAvailable, ReadKey,
TreatControlCAsInput members and the CancelKeyPress event. "
http://wesnerm.blogs.com/net_undocumented/2004/02/console_support.html

"Not Your Grandpa's Console
The BCL class that gains the most new features is the Console class.
Prior to the new features, the Console class allowed limited input and
output buffer access, and interactions limited to very linear
scenarios. Reading and writing task interactions with the screen
buffer were dictated by the simple Read, Write, ReadLine, and
WriteLine methods."

http://www.devx.com/codemag/Article/20150/0/page/5

Marc
 
Back
Top