count numbers selected by randomize

Posted on 2012-09-12
Medium Priority
Last Modified: 2012-09-12
Working on a keno game. have added a Autoplay with an option to stop Auto play after user defined # of times with a max of 2000.if user selects 2000 the the game will randomize  80 numbers with 20 selections for each randomize and update the results with each run. Some one asked me to add a feature to display the most popular number of the 80 being hit.

What could i use to keep track of how many times each number is selected and display the results. Preferably sorted by the highest hit number at the top?
number 1, hit 25 times
number 2, hit 35 times
number 3, hit 55 times
all the way to number 80
Question by:isnoend2001
  • 3
  • 2
LVL 86

Accepted Solution

Mike Tomlinson earned 2000 total points
ID: 38393214
You could keep a simple array and increment the number by incrementing the index value:

    Dim ValueCount(1 to 80) As Long

So if number 40 was picked, you increment index 40:

    ValueCount(40) = ValueCount(40) + 1

Here's some example code for sorting small arrays:

Author Closing Comment

ID: 38393280
thank you pretty simple

Author Comment

ID: 38393316
could you show me how to write this:
Dim mNumberCount(1 To 80) As Long 'form declaration
mNumberCount(i) = DrawnNumber (i)
        mNumberCount(i) = mNumberCount(i) + 1

DrawnNumber (i) is the number selected
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 38393462
It would be something more like

    Dim number As Long
    Dim mNumberCount(1 To 80) As Long 'form declaration

    number = DrawnNumber (i)
    mNumberCount(number) = mNumberCount(number) + 1

Author Comment

ID: 38393470

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question