

12192003, 09:40 AM

Newcomer


Join Date: Nov 2003
Posts: 16


Stack overflow
How do you add 13,000000 items to the list without getting error or delay?
i.e;
Dim i as long
for i = 1 to Clng(13000000)
List1.additem i
next i
The above code stops the program (Not Responding)! How do you fix this problem? Does anyone know?


12192003, 09:51 AM


Martian In Disguise
Retired Moderator * Guru *


Join Date: May 2003
Location: Minneapolis, MN
Posts: 9,566


Personally, I would strongly recommend against placing 13 million items into a ListBox.
Secondly, you could place the DoEvents statement within your For...Loop.

__________________
The only stupid question is the one that goes unasked.

12192003, 01:42 PM


Centurion


Join Date: Jun 2001
Location: Seattle, Wa
Posts: 106


doesnt work for me
Quote: Originally Posted by 00100b Personally, I would strongly recommend against placing 13 million items into a ListBox.
Secondly, you could place the DoEvents statement within your For...Loop.
Just for fun(i would couldnt possibly come up with a reason for actually doing this) I tried this out with the doevents inside the loop. I get an overflow error. I appears to me that the control (listbox or cbobox) has a size limit if 32000 items.
dz

__________________
ouch! it hurts when I do that! ouch! it hurts when I do that! ouch! it hurts when I do that!..................

12192003, 05:52 PM

Newcomer


Join Date: Nov 2003
Posts: 16


Quote: Originally Posted by dzem68
Quote: Originally Posted by 00100b Personally, I would strongly recommend against placing 13 million items into a ListBox.
Secondly, you could place the DoEvents statement within your For...Loop.
Just for fun(i would couldnt possibly come up with a reason for actually doing this) I tried this out with the doevents inside the loop. I get an overflow error. I appears to me that the control (listbox or cbobox) has a size limit if 32000 items.
dz
Actually, I wrote a lottery program for fun too! I could get upto 200,000 five number list in the listbox. But I wanted to get 283700
and 13000000 for the Pick6 numbers which gave me an error or program stopped responding. The idea was to select 10,000 numbers starting with any number from 1 to 45 and buy ten thousand tickets. If the winning number started with the same first number that I picked then I definitly win that five number lottery($100,000). The odds of picking that one number is say 45/1. But then again its a big gamble if you are willing to do it or if ten people share the pot. I have tried this strategy with Pick3 numbers and it worked most of the time.
"There is always a little chance of winning big, but there is a big chance of winning little."


12192003, 06:06 PM

Banned


Join Date: Aug 2003
Posts: 121


*cowers in fear of 13 million items*
anyways, if you really needed to do this, you could create your own listbox control, i did it and it works very nicely.


12192003, 06:55 PM


Codeaholic
Retired Leader * Guru *


Join Date: Oct 2002
Location: Winnipeg, MB, Canada
Posts: 4,543


There is NO NEED EVER, to place that many items in a list. No user will scroll through 13 million items.

__________________
There are 10 types of people in this world, those that understand binary, and those that don't.

12192003, 08:19 PM

Centurion


Join Date: Nov 2003
Posts: 149


Uhm...
13,000,000 items in a list will most certainly require more than
312,000,000 bytes
That's 297.5 megabytes.
Perhaps that's your problem? That's really conservative too. That's one digit numbers, and one space as a seperator(as BSTRs, 2 bytes).
I'd say it'd easily take 400500+ megabytes.
Anyway. I'd open a file for append... and write the data to disk. Then use a good program to view it.

__________________
FireXtol
VB6, C++, HTML, Iptscrae

12192003, 08:41 PM


Algorithms 'R' Us
Forum Leader * Guru *


Join Date: Jun 2002
Location: Canberra
Posts: 4,159


A suitable case for optimisation!. If you need a large array, use a large array, not a control!
And you can encode a 6choice combination from 45 objects into a single Long variable. That'll save 2 bytes per entry if memory is a concern.
EDIT: sorry, that's dead wrong, close but no cigar. It'd have to be Currency, 8 bytes each

__________________
Cogito, ergo codo
Last edited by MathImagics; 12192003 at 08:51 PM.

12202003, 05:25 AM

Centurion


Join Date: Nov 2003
Posts: 149


I'd do something like this:
Code:
Type tPick6
bytNum(5) as Byte
End Type
Dim Pick6 as tPick6
You can then open the file for binary, and continue to refill the pick6, and write the UDT at the end of the file.
This way, for 13mil series, it'd only take 78,000,000 bytes. Then use a hex editor to view them?

__________________
FireXtol
VB6, C++, HTML, Iptscrae

12202003, 05:40 PM


Algorithms 'R' Us
Forum Leader * Guru *


Join Date: Jun 2002
Location: Canberra
Posts: 4,159


Quote: Originally Posted by kendo The idea was to select 10,000 numbers starting with any number from 1 to 45 and buy ten thousand tickets. If the winning number started with the same first number that I picked then I definitly win that five number lottery($100,000). The odds of picking that one number is say 45/1. The odds of picking that one number is say 45/1
If you fix the first number, and it turns up, there are still 44 numbers from which the remaining 5 numbers will be chosen. This gives C(44, 5) = 1,086,008 combinations, so your 10,000 tickets can not possibly guarantee you a 6number prize.
If 4 of your other numbers match, you'll get your 5 numbers, but the overall chance of a 5number match from any one of your 6number tickets remains immutably fixed at:  Ways to draw 6 numbers from 45, A = C(45, 6) = 8,145,060
 Number of ways to draw 6 that include my 5 numbers, B = C(455, 65) = 40
 Ergo, chances of a 6number draw including my 5 fixed numbers, X = B / A, or about 203,625 to 1
No matter how you choose the numbers, ONE 6number ticket has ONE chance in 203,625 of getting a 5number match. End of story
See a similar discussion at this thread http://www.xtremevbtalk.com/showthread.php?t=129733

__________________
Cogito, ergo codo

12202003, 08:19 PM

Newcomer


Join Date: Sep 2003
Posts: 22


Hello
ListBox, like other controls are intended to DISPLAY info, not to STORE data. Use an array to store data. If you still want amaze user with such a huge listbox, you can load first portion, then wait some hours (days?) while user scroll it to the bottom and replace list box content with next portion (same way when user scroll back to the top).


12212003, 11:05 AM

Newcomer


Join Date: Nov 2003
Posts: 16


Quote: Originally Posted by MathImagics
Quote: Originally Posted by kendo The idea was to select 10,000 numbers starting with any number from 1 to 45 and buy ten thousand tickets. If the winning number started with the same first number that I picked then I definitly win that five number lottery($100,000). The odds of picking that one number is say 45/1. The odds of picking that one number is say 45/1
If you fix the first number, and it turns up, there are still 44 numbers from which the remaining 5 numbers will be chosen. This gives C(44, 5) = 1,086,008 combinations, so your 10,000 tickets can not possibly guarantee you a 6number prize.
If 4 of your other numbers match, you'll get your 5 numbers, but the overall chance of a 5number match from any one of your 6number tickets remains immutably fixed at: Ways to draw 6 numbers from 45, A = C(45, 6) = 8,145,060
 Number of ways to draw 6 that include my 5 numbers, B = C(455, 65) = 40
 Ergo, chances of a 6number draw including my 5 fixed numbers, X = B / A, or about 203,625 to 1
No matter how you choose the numbers, ONE 6number ticket has ONE chance in 203,625 of getting a 5number match. End of story
See a similar discussion at this thread http://www.xtremevbtalk.com/showthread.php?t=129733
Let me give you the strategy for Pick3 numbers and you will be able to see clearly what I am talking about. The same stragtegy can work for Pick6 numbers also(if you think about it). In Pick3 you have to pick 3 numbers out of 09 numbers. Now if you make a database of numbers as following:
1. Each number pairs with itself
2. Each number pairs with the other number from 09
3. Since we only need 3 numbers the list will go from 000 upto 999.
Use this database to load these numbers into a listbox and before loading it add a function to scramble them individually i.e; 123,132,321,213,312,231. So there will be six scrambles for each triplet. Now when your list is full you will see that you have 1000 total set of 3 numbers in your list(not including duplicates). The odds of winning is 1 in a 1000. Now go back to what what I was saying. If you see on the list there is only a pack of 100 numbers starting with an integer from 09. If you pick that first number and buy 100 tickets you will definilty win the $500 lottery if your number started with that number that you chose. The odds are 1/9 of chosing that number. Now in five draws you are most likely to win three times if you play wisely. Similarly, you can do this with Pick6 numbers but I have'nt been able to print all those 13,983,816 numbers and find out exactly what the statistics are. My guess is its going to be a purchase of 285,384 tickets minimum. The odds of picking that one number will be 1 in 49. Try this and let me know what you think.
Note: You could use ForLoop to generate numbers and forget about database entry.

Last edited by kendo; 12212003 at 02:17 PM.

12212003, 07:53 PM


Algorithms 'R' Us
Forum Leader * Guru *


Join Date: Jun 2002
Location: Canberra
Posts: 4,159


Quote: Originally Posted by kendo Similarly, you can do this with Pick6 numbers but I have'nt been able to print all those 13,983,816 numbers and find out exactly what the statistics are. My guess is its going to be a purchase of 285,384 tickets minimum. The odds of picking that one number will be 1 in 49.
The good news, my friend, is that 285,384 is absolutely right.
The bad news, I'm afraid is that 285,384 x 49 = 13,983,816
285,384 is C(49, 5), which is exactly how many different tickets you need to to cover all possible combinations of 5 numbers! No strategy permitted.
Buy that many tickets, put the same first number on every one, and every possible combination of the other 5 numbers on each one, then yes, you have just a 1 in 49 chance of getting the big prize.
For a $100,000 lottery, a ticket will cost, what say 10 cents, that's nearly $30,000 it'll cost you to have a 491 chance of a lousy 21 payoff? No way!
If tickets are in fact 20 cents it gets worse! They cost you $60,000, further reducing your profit to a measly 40% (1 time in 50, that is!)
Sorry, but you can't improve the chance of any ticket in any way, shape or form!

__________________
Cogito, ergo codo
Last edited by MathImagics; 12212003 at 08:02 PM.

12212003, 08:16 PM

Newcomer


Join Date: Nov 2003
Posts: 16


Quote: Originally Posted by MathImagics
Quote: Originally Posted by kendo Similarly, you can do this with Pick6 numbers but I have'nt been able to print all those 13,983,816 numbers and find out exactly what the statistics are. My guess is its going to be a purchase of 285,384 tickets minimum. The odds of picking that one number will be 1 in 49.
The good news, my friend, is that 285,384 is absolutely right.
The bad news, I'm afraid is that 285,384 x 49 = 13,983,816
285,384 is C(49, 5), which is exactly how many different tickets you need to to cover all possible combinations of 5 numbers! No strategy permitted.
Buy that many tickets, put the same first number on every one, and every possible combination of the other 5 numbers on each one, then yes, you have just a 1 in 49 chance of getting the big prize.
For a $100,000 lottery, a ticket will cost, what say 10 cents, that's nearly $30,000 it'll cost you to have a 491 chance of a lousy 21 payoff? No way!
If tickets are in fact 20 cents it gets worse! They cost you $60,000, further reducing your profit to a measly 40% (1 time in 50, that is!)
Sorry, but you can't improve the chance of any ticket in any way, shape or form!
I agree with the first part but there is a correction to be made on the second part. I was banking on a $1 lottery. If the lottery ticket costs 10cents then you only have to bet $10 to buy 100 tickets on the Pick3 lottery to win $500. Playing 9 times out of 10 can definitly increase your odds of winning 90%. So betting 90 to win 500 is not a bad bargain at all...me thinks!


12212003, 10:24 PM


Algorithms 'R' Us
Forum Leader * Guru *


Join Date: Jun 2002
Location: Canberra
Posts: 4,159


It seems to me this "Pick3" is a different game to Pick6? I've searched the web but can only find "Guaranteed Win" systems for various amounts of money!!! It looks like it's picking a 3digit number in the right order, without repetitions?
If that's the case, the maths is totally different to Pick "6 from 49". There are C(10,3) = 120 ways to pick 3 digits, and 6 ways to order them, so there's 720 possible outcomes.
But as I understand it the ticket price is $1, not 10 cents
The game makes money simply by offering a 499to1 return on a 1 in 720 chance. If you bet $100 you get a 41 return but your chances remain 1 in 7.2
The bank gets a pretty steady $220 for each 720 tickets sold, nice work if you can get it
I have to say it, I can't believe how MANY GetPick3Quick schemes there I had to wade through to get some info  and people are really paying money for them

__________________
Cogito, ergo codo
Last edited by MathImagics; 12212003 at 10:30 PM.

12222003, 10:41 AM

Newcomer


Join Date: Nov 2003
Posts: 16


Quote: Originally Posted by MathImagics It seems to me this "Pick3" is a different game to Pick6? I've searched the web but can only find "Guaranteed Win" systems for various amounts of money!!! It looks like it's picking a 3digit number in the right order, without repetitions?
If that's the case, the maths is totally different to Pick "6 from 49". There are C(10,3) = 120 ways to pick 3 digits, and 6 ways to order them, so there's 720 possible outcomes.
But as I understand it the ticket price is $1, not 10 cents
The game makes money simply by offering a 499to1 return on a 1 in 720 chance. If you bet $100 you get a 41 return but your chances remain 1 in 7.2
The bank gets a pretty steady $220 for each 720 tickets sold, nice work if you can get it
I have to say it, I can't believe how MANY GetPick3Quick schemes there I had to wade through to get some info  and people are really paying money for them
I must say you are very good at math, but i can tell you have'nt ran the program yet. I can tell you this much that i have won $9000 so far and lost only $300. Maybe I have been lucky. I had a good start to build up my bank and then i could take more risk. I have'nt tried
this twisted logic with Pick6 yet but my gutt feeling is that it could be possible. If you read the news about some guys from Australia who won millions by purchasing all the probable numbers gives some idea how they did it.But you are right it is a gamble after all and the people who made the lottery are'nt so stupid.


12222003, 11:15 AM


Contributor


Join Date: Sep 2003
Location: New Jer$ey
Posts: 540


The Pick3 is picking 3 numbers to make a number from 000 to 999. Ex. I buy a ticket with 856 and there are 3 machines, each with pingpong balls numbered 0 to 9 to make the winning combination.
The Pick6 however, is one large machine with all of the ping pong balls together numbered 149. No repeats.


12222003, 12:31 PM

Newcomer


Join Date: Nov 2003
Posts: 16


Quote: Originally Posted by vbFace The Pick3 is picking 3 numbers to make a number from 000 to 999. Ex. I buy a ticket with 856 and there are 3 machines, each with pingpong balls numbered 0 to 9 to make the winning combination.
The Pick6 however, is one large machine with all of the ping pong balls together numbered 149. No repeats.
Agree with that. Assuming That machine has six slots and spits out
a different number each time in any order.The numbers range from 149.
If you make a list of all possible Random set of 6 numbers and sort them out. Then see how many numbers you get that start with the same number? Then buy all those numbers. Even then you will be left with
a chance of 1/49 of winning. If one of the 49 numbers is your number then you definitly win the pot. It is as simple as that. The difficult part is who is going to risk $285,384 to win whatever the amount of pot?


12222003, 01:49 PM


Contributor


Join Date: Sep 2003
Location: New Jer$ey
Posts: 540


Better yet, who is going to actually process 285,384 lottery tickets at the local 711? LOL


12222003, 01:57 PM

Senior Contributor
Forum Leader


Join Date: Oct 2003
Location: Central Florida
Posts: 1,276


Quote: Originally Posted by vbFace Better yet, who is going to actually process 285,384 lottery tickets at the local 711? LOL
I've stood in line behind that guy when all I wanted was gasoline.

__________________
 D.J.
I do not endorse any items advertised within this frame, and regret that the viewer is subjected to such.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)


Thread Tools 

Display Modes 
Linear Mode

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off





