I’m just learning to code in vb.net and am currently messing around with VB.net console applications. I can’t for the life of me figure something out. It’s probably been asked before on here, but I can’t find anything by searching. I just coded a simple “check if Y or N was entered. If y/n was entered, display ‘you have entered y/n'” program, and it works fine the first time. However, after the first entry I can’t get the process to repeat. All I get back is blank space. For example, if i enter y, I’ll get the corresponding message. however, if after that I enter n I get nothing back.
here’s the code:
Module Module1
Sub Main()
Console.Title = "Hello"
Console.WriteLine("Y or N")
Dim line As String
line = Console.ReadLine()
Do Until line = "exit"
If line = "y" Then
Console.WriteLine("you have chosen y")
Console.ReadLine()
ElseIf line = "n" Then
Console.WriteLine("you have chosen n")
Console.ReadLine()
End If
line = ""
Loop
End Sub
End Module
I’m assuming the answer’s super simple, but I can’t seem to figure it out or fin the answer online.
Thanks for the help.
You have to store the value of Console.ReadLine() in the Line string.
End Module