: Right I finally seem to be getting somewhere with this now, I've got the whole checking procedure working which seems to be counting the number of matches correctly, now all I need to do is to incorporate the random winning numbers. The way I have decided to do it (which probably isn't the easiest way but oh well!) is to randomly create each of the numbers seperatley using the text boxes and then putting them into the array, so so far I have got the simple part.
:
: In the form load I have:
: txtWinningNumbers(0).Text = Int((49 * Rnd) + 1)
: txtWinningNumbers(1).Text = Int((49 * Rnd) + 1)
: txtWinningNumbers(2).Text = Int((49 * Rnd) + 1)
: txtWinningNumbers(3).Text = Int((49 * Rnd) + 1)
: txtWinningNumbers(4).Text = Int((49 * Rnd) + 1)
: txtWinningNumbers(5).Text = Int((49 * Rnd) + 1)
:
: Now what I need is some kind of looped if statement that basically says
:
: Loop until all of the random numbers are different.
:
: Could I do this simply by saying
:
: Loop until txtWinningNumbers(0), txtWinningNumbers(1) ...... are not the same???? How would I enter this in correct code??
:
Try something like this:
dim x,intcount,newvalue as integer
dim blnPass as Boolean
Randomize 'you need this for random numbers
intcount = 0
do while intcount < 6
newvalue = (49 - 0 + 1) * Rnd + 1
blnPass = true
for x = 0 to 5
if newvalue = Winningnum(x) then
blnpass= false
End if
next x
if blnpass = true then
Winningnum(intcount) = newvalue
intcount = intcount + 1
end if
Loop
C:\Dos
C:\Dos Run
Run Dos Run