# Need help with simple guess/lottery program

Page 1 of 1

## 2 Replies - 1133 Views - Last Post: 08 May 2013 - 05:32 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=320589&amp;s=d25c1da7d6e74179e46239d643918a95&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 hurdlinghurdles

• New D.I.C Head

Reputation: 0
• Posts: 4
• Joined: 08-May 13

# Need help with simple guess/lottery program

Posted 08 May 2013 - 02:56 PM

Hi,

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.

Is This A Good Question/Topic? 0

## Replies To: Need help with simple guess/lottery program

### #2 andrewsw

• I'm not here to twist your niblets

Reputation: 4276
• Posts: 15,682
• Joined: 12-December 12

## Re: Need help with simple guess/lottery program

Posted 08 May 2013 - 03:27 PM

You could use another variable:

```Dim intGuesses As Integer = 0
```

and just increase this after every guess, checking if it reaches 5.

Quote

I just started learning my first language

I like the enthusiasm that this implies

### #3 hurdlinghurdles

• New D.I.C Head

Reputation: 0
• Posts: 4
• Joined: 08-May 13

## Re: Need help with simple guess/lottery program

Posted 08 May 2013 - 05:32 PM

Thank you that worked nicely!