Stack overflow
Stack overflow
Stack overflow
Stack overflow
Stack overflow
Stack overflow Stack overflow Stack overflow Stack overflow Stack overflow Stack overflow Stack overflow Stack overflow
Stack overflow Stack overflow
Stack overflow
Go Back  Xtreme Visual Basic Talk > > > Stack overflow


Reply
 
Thread Tools Display Modes
  #1  
Old 12-19-2003, 09:40 AM
kendo kendo is offline
Newcomer
 
Join Date: Nov 2003
Posts: 16
Default 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?
Reply With Quote
  #2  
Old 12-19-2003, 09:51 AM
00100b's Avatar
00100bStack overflow 00100b is offline
Martian In Disguise

Retired Moderator
* Guru *
 
Join Date: May 2003
Location: Minneapolis, MN
Posts: 9,566
Default

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 un-asked.
Reply With Quote
  #3  
Old 12-19-2003, 01:42 PM
dzem68's Avatar
dzem68 dzem68 is offline
Centurion
 
Join Date: Jun 2001
Location: Seattle, Wa
Posts: 106
Default 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!..................
Reply With Quote
  #4  
Old 12-19-2003, 05:52 PM
kendo kendo is offline
Newcomer
 
Join Date: Nov 2003
Posts: 16
Default

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."
Reply With Quote
  #5  
Old 12-19-2003, 06:06 PM
4d5e6f 4d5e6f is offline
Banned
 
Join Date: Aug 2003
Posts: 121
Default

*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.
Reply With Quote
  #6  
Old 12-19-2003, 06:55 PM
Optikal's Avatar
OptikalStack overflow Optikal is offline
Codeaholic

Retired Leader
* Guru *
 
Join Date: Oct 2002
Location: Winnipeg, MB, Canada
Posts: 4,543
Default

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.
Reply With Quote
  #7  
Old 12-19-2003, 08:19 PM
FireXtol FireXtol is offline
Centurion
 
Join Date: Nov 2003
Posts: 149
Default

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 400-500+ 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
Reply With Quote
  #8  
Old 12-19-2003, 08:41 PM
Mathimagics's Avatar
MathimagicsStack overflow Mathimagics is offline
Algorithms 'R' Us

Forum Leader
* Guru *
 
Join Date: Jun 2002
Location: Canberra
Posts: 4,159
Default

A suitable case for optimisation!. If you need a large array, use a large array, not a control!

And you can encode a 6-choice 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; 12-19-2003 at 08:51 PM.
Reply With Quote
  #9  
Old 12-20-2003, 05:25 AM
FireXtol FireXtol is offline
Centurion
 
Join Date: Nov 2003
Posts: 149
Default

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
Reply With Quote
  #10  
Old 12-20-2003, 05:40 PM
Mathimagics's Avatar
MathimagicsStack overflow Mathimagics is offline
Algorithms 'R' Us

Forum Leader
* Guru *
 
Join Date: Jun 2002
Location: Canberra
Posts: 4,159
Default

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 6-number prize.

If 4 of your other numbers match, you'll get your 5 numbers, but the overall chance of a 5-number match from any one of your 6-number 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(45-5, 6-5) = 40
  • Ergo, chances of a 6-number draw including my 5 fixed numbers, X = B / A, or about 203,625 to 1

No matter how you choose the numbers, ONE 6-number ticket has ONE chance in 203,625 of getting a 5-number match. End of story

See a similar discussion at this thread http://www.xtremevbtalk.com/showthread.php?t=129733
__________________
Cogito, ergo codo
Reply With Quote
  #11  
Old 12-20-2003, 08:19 PM
Ark Ark is offline
Newcomer
 
Join Date: Sep 2003
Posts: 22
Default

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).
Reply With Quote
  #12  
Old 12-21-2003, 11:05 AM
kendo kendo is offline
Newcomer
 
Join Date: Nov 2003
Posts: 16
Default

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 6-number prize.

If 4 of your other numbers match, you'll get your 5 numbers, but the overall chance of a 5-number match from any one of your 6-number 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(45-5, 6-5) = 40
  • Ergo, chances of a 6-number draw including my 5 fixed numbers, X = B / A, or about 203,625 to 1

No matter how you choose the numbers, ONE 6-number ticket has ONE chance in 203,625 of getting a 5-number 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 0-9 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 0-9
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 0-9. 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 For-Loop to generate numbers and forget about database entry.

Last edited by kendo; 12-21-2003 at 02:17 PM.
Reply With Quote
  #13  
Old 12-21-2003, 07:53 PM
Mathimagics's Avatar
MathimagicsStack overflow Mathimagics is offline
Algorithms 'R' Us

Forum Leader
* Guru *
 
Join Date: Jun 2002
Location: Canberra
Posts: 4,159
Default

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 49-1 chance of a lousy 2-1 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; 12-21-2003 at 08:02 PM.
Reply With Quote
  #14  
Old 12-21-2003, 08:16 PM
kendo kendo is offline
Newcomer
 
Join Date: Nov 2003
Posts: 16
Default

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 49-1 chance of a lousy 2-1 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!
Reply With Quote
  #15  
Old 12-21-2003, 10:24 PM
Mathimagics's Avatar
MathimagicsStack overflow Mathimagics is offline
Algorithms 'R' Us

Forum Leader
* Guru *
 
Join Date: Jun 2002
Location: Canberra
Posts: 4,159
Default

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 3-digit 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 499-to-1 return on a 1 in 720 chance. If you bet $100 you get a 4-1 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 Get-Pick3-Quick 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; 12-21-2003 at 10:30 PM.
Reply With Quote
  #16  
Old 12-22-2003, 10:41 AM
kendo kendo is offline
Newcomer
 
Join Date: Nov 2003
Posts: 16
Default

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 3-digit 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 499-to-1 return on a 1 in 720 chance. If you bet $100 you get a 4-1 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 Get-Pick3-Quick 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.
Reply With Quote
  #17  
Old 12-22-2003, 11:15 AM
vbFace's Avatar
vbFace vbFace is offline
Contributor
 
Join Date: Sep 2003
Location: New Jer$ey
Posts: 540
Default

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 ping-pong 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 1-49. No repeats.
Reply With Quote
  #18  
Old 12-22-2003, 12:31 PM
kendo kendo is offline
Newcomer
 
Join Date: Nov 2003
Posts: 16
Default

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 ping-pong 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 1-49. 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 1-49.
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?
Reply With Quote
  #19  
Old 12-22-2003, 01:49 PM
vbFace's Avatar
vbFace vbFace is offline
Contributor
 
Join Date: Sep 2003
Location: New Jer$ey
Posts: 540
Default

Better yet, who is going to actually process 285,384 lottery tickets at the local 7-11? LOL
Reply With Quote
  #20  
Old 12-22-2003, 01:57 PM
ElderKnightStack overflow ElderKnight is offline
Senior Contributor

Forum Leader
 
Join Date: Oct 2003
Location: Central Florida
Posts: 1,275
Default

Quote:
Originally Posted by vbFace
Better yet, who is going to actually process 285,384 lottery tickets at the local 7-11? 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.
Reply With Quote
Reply


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Overflow Help galaganut Word, PowerPoint, Outlook, and Other Office Products 3 11-20-2003 02:03 PM
Stack Overflow in MouseMove event brett_s Game Programming 4 07-22-2003 10:39 PM
Calling a sub recursively?? mms General 6 03-02-2003 04:15 PM
Out Of Stack Space and one other question... NeverDie Game Programming 8 02-07-2002 05:12 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Stack overflow
Stack overflow
Stack overflow Stack overflow
Stack overflow
Stack overflow
Stack overflow Stack overflow Stack overflow Stack overflow Stack overflow Stack overflow Stack overflow
Stack overflow
Stack overflow
 
Stack overflow
Stack overflow
 
-->