I am trying to understand how to detect a simple keypress while running a console application under vb.net.
In short I would like a loop to repeat continuously until a key press is detected at which point it would exit the loop.
I have this so far:
Module Module1
Private theKey As ConsoleKeyInfo = New ConsoleKeyInfo
Sub Main()
Do
'theKey = Console.ReadKey(True)
Select Case theKey.Key
Case ConsoleKey.Enter
Exit Do
Case Else
Console.WriteLine("Hello World")
End Select
Loop
End Sub
End Module
...but this requires a key press every iteration which is what I am trying to avoid, however the enter keypress does exit the loop so part of it is work.
Any ideas?
Egon
In short I would like a loop to repeat continuously until a key press is detected at which point it would exit the loop.
I have this so far:
Module Module1
Private theKey As ConsoleKeyInfo = New ConsoleKeyInfo
Sub Main()
Do
'theKey = Console.ReadKey(True)
Select Case theKey.Key
Case ConsoleKey.Enter
Exit Do
Case Else
Console.WriteLine("Hello World")
End Select
Loop
End Sub
End Module
...but this requires a key press every iteration which is what I am trying to avoid, however the enter keypress does exit the loop so part of it is work.
Any ideas?
Egon