Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro for LOTO Drawing!

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Macro for LOTO Drawing!

Like the LOTO each number has an equal chance of appearing at each stage, so
every combination has an 'equal' chance of appearing. However the number
generator is pseudo random and you cannot guarantee this result, but then
winning the LOTO is just as unlikely!

Good Luck
Nigel

"alainB " wrote in message
...
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 when

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 Sub


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro for LOTO Drawing!

Thanks!

If you draw 6 numbers out of 49, put them back and do it again, th
chance for the second serie to be the same as the first one is about
in 15 millions (more or less a few millions, I suppose??).

Because the computer generate a pseudo random number, and it is bas
based on the timer seed, I remember somebody saying somewhere that i
was not possible to generate more than 60 or 70 thousands different
series.

If so, my macro would not be good at all.

??

Alai

--
Message posted from http://www.ExcelForum.com

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro for LOTO Drawing!

Have you tried multiplying two random numbers together, that should give you
a couple of spares as well.

"alainB " wrote in message
...
Thanks!

If you draw 6 numbers out of 49, put them back and do it again, the
chance for the second serie to be the same as the first one is about 1
in 15 millions (more or less a few millions, I suppose??).

Because the computer generate a pseudo random number, and it is base
based on the timer seed, I remember somebody saying somewhere that it
was not possible to generate more than 60 or 70 thousands differents
series.

If so, my macro would not be good at all.

??

Alain


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Macro for LOTO Drawing!

Not true!

You are creating a random selection for each selection, therefore there is
an equal chance (within the probability density of the randomising process)
to get 1 to 49 each time. The seed applies for each selection event so the
probabilities stay the same.
You will not limit the series to a subset of the possible permutations.

The only issue is that you could randomly select one of the numbers already
in the series, so your true probability is not reduing as it is in the
'real' selection process. But since you reject that and reselect another
number the outcome is not affected.

Still does not improve your chances of winning the real loto though!

Cheers
Nigel

"alainB " wrote in message
...
Thanks!

If you draw 6 numbers out of 49, put them back and do it again, the
chance for the second serie to be the same as the first one is about 1
in 15 millions (more or less a few millions, I suppose??).

Because the computer generate a pseudo random number, and it is base
based on the timer seed, I remember somebody saying somewhere that it
was not possible to generate more than 60 or 70 thousands differents
series.

If so, my macro would not be good at all.

??

Alain


---
Message posted from http://www.ExcelForum.com/





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default Macro for LOTO Drawing!

Alain

Here's another way. It uses worksheet formulas, but you could program the
whole thing. The main advantage is that you don't have to test for
duplicates.

http://www.dicks-blog.com/excel/2004..._a_winner.html

--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com



"alainB " wrote in message
...
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 when

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 Sub


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Record a macro will not edit composite drawing object Walter Briscoe New Users to Excel 4 January 12th 09 10:49 PM
how do i prepare a macro to insert drawing object on specific cell Harshad[_2_] Excel Discussion (Misc queries) 2 November 25th 08 08:06 AM
Drawing print-out pangtc Excel Worksheet Functions 0 May 23rd 06 11:58 AM
What is Drawing Canvas? JakeA Excel Discussion (Misc queries) 2 March 7th 06 12:18 AM
Selecting drawing objects or shapes in a macro John DeFiore Excel Programming 3 October 13th 03 02:26 PM


All times are GMT +1. The time now is 10:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"