Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27199

Need help with a loop in vb.net console

$
0
0
I am really new to VB and have a question about loops. I am programming a console based text adventure and need to know how to make the wrong choice loop back to the selection. By wrong, I mean something that's not even a choice. Like below, when someone puts in '3'. I want it to say ("What is so hard about '1' or '2'. Pick a number between 1 and 2....") and then repeat the question with the choices. Any help is appreciated.

Console.WriteLine("Do you want to quit or get started? Type the corresponding number")
Console.WriteLine("and press ENTER to submit your choice.")
Console.WriteLine()
Console.WriteLine("1. Get Started!")
Console.WriteLine("2. No Thanks!")

Begin = Console.ReadLine()
If Begin = 1 Then
Console.WriteLine("Let's get started!")
Console.ReadKey()
ElseIf Begin = 2 Then
Console.WriteLine("See ya next time!")
Console.ReadKey()
Else
Console.WriteLine("What is so hard about '1' or '2'. Pick a number between 1 and 2....")
Console.ReadLine()
End If


PS. Sorry for no indentions. kinda new to the forum thing, too.

Viewing all articles
Browse latest Browse all 27199

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>