Console: Read |
Reads a character from the current input source.
Public Function Read ( ) As Long
The Read method does not return until the Return key is pressed. Once the function returns, it can be called repeatedly until all key presses upto the return key are retrieved. The return key is also returned as a carriage-return (13) followed by a line-feed (10).
This example shows how to read input from the console keyboard. The Read function will block and wait for the return key to be pressed before returning. If there are characters already in the input stream, the function does not block and returns the next character.
Private Sub Main() Dim ch As Long ' reads from the console keyboard. The function ' will block until the return key is pressed. ch = Console.Read ' we will loop through the characters typed into ' the console and exit the loop when CTRL+Z followed ' by Return is pressed. Do While ch <> 26 Debug.Print Chr$(ch); DoEvents ' As long as there are characters remaining to be ' from the console keyboard, this function won't block. ch = Console.Read Loop End Sub