Hey, ive been creating this number guessing game, it works perfectly but I need to add a limit to the amount of turns a user can have.
Any help would be greatly appreciated.
Module Module1
Sub Main()
'This program plays a simple number guessing game.
Dim RandNum As Integer
Dim RandomGenerator As New System.Random
Dim UserGuess As Integer
Dim Turns As Integer
Console.Clear()
RandNum = RandomGenerator.Next(1, 10)
Console.WriteLine("{0}", RandNum)
Console.SetCursorPosition(20, 12)
Console.Write("Enter Your Guess :")
UserGuess = Console.ReadLine()
While UserGuess <> RandNum
If UserGuess < RandNum Then
Console.Clear()
Console.SetCursorPosition(20, 14)
Console.WriteLine("{0} Is Wrong. Too Small.", UserGuess)
ElseIf UserGuess > RandNum Then
Console.Clear()
Console.SetCursorPosition(20, 14)
Console.WriteLine("{0} Is Wrong. Too Big.", UserGuess)
End If
Console.SetCursorPosition(20, 12)
Console.Write("Enter Your Guess :")
UserGuess = Console.ReadLine()
End While
Console.SetCursorPosition(20, 14)
Console.WriteLine("{0} Is Correct! Well Done", UserGuess)
Console.ReadKey()
End Sub
End Module