count numbers selected by randomize

Posted on 2012-09-12
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
    LVL 85

    Accepted Solution

    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

    thank you pretty simple

    Author Comment

    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 85

    Expert Comment

    by:Mike Tomlinson
    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    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…
    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…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now