[AccessD] Random numbers lottery-style

Jim DeMarco Jdemarco at hudsonhealthplan.org
Thu Mar 3 14:22:04 CST 2005


The collection will reindex itself.  There will be one less item for each iteration so you'll have to use the Count property of the Collection to determine the upper bound of the index in your random selection process.

Jim D.

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Steve Erbach
Sent: Thursday, March 03, 2005 3:03 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Random numbers lottery-style


JIm,

I'd forgotten about collections. So, lets say we have a collection like thise:

col(1) = 16
col(2) = 18
col(3) = 27
col(4) = 29
...
col(29) = 147

So we generate a random number from 1 to 29 and zoom in on that index
in the collecition. If the selected number is 4 then I pick col(4) and
then remove that item from the collection for the next go round.

But how, then, do I pick the Nth collection item if the indexes are
non-continguous? Or does the collection re-index itself after removing
an item?

Steve Erbach



On Thu, 3 Mar 2005 14:28:06 -0500, Jim DeMarco
<Jdemarco at hudsonhealthplan.org> wrote:
> Steve,
> 
> Rather than an array how about using the VBA Collection object which will allow you to remove an item.  Add your Activity ID items to a Collection with your numeric value as the key value.
> 
> HTH,
> 
> Jim DeMarco
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


 



***********************************************************************************
"This electronic message is intended to be for the use only of the named recipient, and may contain information from Hudson Health Plan (HHP) that is confidential or privileged.  If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this message is strictly prohibited.  If you have received this message in error or are not the named recipient, please notify us immediately, either by contacting the sender at the electronic mail address noted above or calling HHP at (914) 631-1611. If you are not the intended recipient, please do not forward this email to anyone, and delete and destroy all copies of this message.  Thank You".
***********************************************************************************




More information about the AccessD mailing list