Hi,
This is a macro that I made to choose numbers for the 6/49 loto
that we have here in Quebec. This is a little bit primitive, I
suppose, as I am not very litterate about programing. Hope somebody
will make it better.
I think that there is about 15 millions differents possiblilities whe
drawing 6 numbers out of 49.
Is there a chance that the computer will not generate all those
possibilities but just a few, maybe 60 or 70 thousands?
I am really not shure about that.
What do you think?
Alain
Sub Loto()
a = Array(1, 2, 3, 4, 5, 6)
Start:
'Put a random number betwen 1 and 49 in each array
For i = 0 To 5
Randomize Timer
a(i) = Int((49 * Rnd) + 1)
Next
'Be shure the same number is not there twice, if so start again
x = 0
y = 1
Check:
For z = y To 5
If a(x) = a(z) Then
GoTo Start
End If
Next
x = x + 1
y = y + 1
If y 5 Then GoTo continue
GoTo Check
continue:
'Sorting them
SortStart:
x = 0
y = 1
SortNext:
If a(x) a(y) Then
temp1 = a(x)
temp2 = a(y)
a(x) = temp2
a(y) = temp1
GoTo SortStart
End If
x = x + 1
y = y + 1
If y 5 Then GoTo SortEnd
GoTo SortNext
SortEnd:
'Show the 6 luckly numbers
List = ""
For i = 0 To 5
List = List & a(i)
If i < 5 Then List = List & " - "
Next
MsgBox List
End Su
--
Message posted from
http://www.ExcelForum.com