I just started learning my first language, Visual Basic and am currently working on a lottery program. The program generates 10 winning numbers from 101-200 and then compares to a number the user input into a textbox to see if the user's number was a winning number. My problem is that I need to allow the user 5 guesses before a new set of winning numbers is generated and I do not know how to do this.
My code so far: https://gist.github....5ace55a78476fd9
'Public Array Dim intLotNums(9) As Integer 'RNG Code Dim intNewNum As Integer Dim mGenRand As Random = New Random Dim intCount As Integer = 0 For i = LBound(intLotNums) To UBound(intLotNums) intNewNum = mGenRand.Next(intLowLmt, intUpLmt + 1) intLotNums(intCount) = intNewNum intCount += 1 Next For intCount = 0 To 9 Debug.WriteLine(intLotNums(intCount)) Next 'Test guess code Dim dblGuessNum As Double = CDbl(txtGuessNumber.Text) For i = LBound(intLotNums) To UBound(intLotNums) If dblGuessNum = CDbl(intLotNums(i)) Then MsgBox("Congratulations you won the lottery!") End If Next
intUpLmt and intLowLmt are both constants set to the lowest and highest possible values of the lottery numbers.
The form itself has a txtbox, a "play" button, a reset button and a quit button.
Thank you for any help.
This post has been edited by Atli: 08 May 2013 - 03:13 PM
Reason for edit:: Please post your code here, in [code] tags, rather than linking to them elsewhere. Links tend not to last.