How would you be able to read less than the standard 254 characters from the console, in VB.NET with Console.ReadLine()
?
I have tried using Console.ReadKey()
:
Dim A As String = ""
Dim B As Char
For i = 0 To 10
B = Console.ReadKey().KeyChar
A = A & B
Next
MsgBox(A)
It limits me and it returns the string, but how could it work if a user was to enter less than 10 characters?
To limit the input to 10 characters, while allowing for less that 10 characters to be entered by pressing the Enter key, you can use a loop like this. It checks for the enter key and exits the loop if it's pressed, or the loop will naturally end once 10 characters have been entered.
EDIT - updated per comments