So, recently I started trying to make a text based game with console application in VB. However, I stumbled across a certain problem I couldn't fix. I wanted to give the player two choices. So, they have the option to pick door no.1 or door no.2. I tried to do this with an If Else statement but couldn't seem to get it working as the part after the Else reads another Console.ReadLine() instead of reading the same one. Valve, pls fix.
Function BooleanPrompt(prompt As String) As Boolean
Do
Console.Write("{0} (y/n) ", prompt)
Select Case Console.ReadLine().ToLower()
Case "y", "yes"
Return True
Case "n", "no"
Return False
End Select
Loop
End Function
use
Code:
if BooleanPrompt("Door 1?") = true then
else
console.writeline("You chose Door 2")
end if
if you press Y and press Enter it will return true, if N it will return false.