Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.visual.basic    |    MS Visual Basic discussions, NOT dot-net    |    10,840 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 9,133 of 10,840    |
|    Hal Rosser to Arthur Meineke    |
|    Re: Newbie needs help    |
|    01 Jan 05 22:10:15    |
   
   From: hmrosser@bellsouth.net   
      
   "Arthur Meineke" wrote in message   
   news:zvxBd.40565$yv2.4982@fe2.texas.rr.com...   
   > I am trying to teach myself VB 6.0 using books. I am making a simple   
   > lotto-picker just to see if I can do it. I don't plan to make a living   
   doing   
   > this. The problem is that I can't figure out an easy way to avoid repeats.   
   > There is   
   > probably a small snippet of code that will do the job, but I can't find   
   it.   
   > Following is the code I am using. If you know what I can add to avoid   
   > repeats I would surely appreciate it.   
   >   
      
   Assuming the lotto picks numbers from 1 to 50   
   Declare an array (Boolean type) - (size 1 to 50)   
   assign all values of the array the value 'false'   
   Declare a counter variable.to keep track of the number of lotto numbers   
   chosen.   
   Assuming you need to pick 6 numbers, here's what to do:   
   Get a random number (we'll call it RN)   
   use the random number as the array index.   
   If the array(RN) = false then add 1 to the counter and assign 'true' to the   
   array(RN)   
      
   --but if the array(RN) is already true - don't use the number and don't add   
   to the counter.   
   Its a simple direct-access way of solving your problem, with no need for   
   shuffling a deck   
      
      
      
      
      
   ---   
   Outgoing mail is certified Virus Free.   
   Checked by AVG anti-virus system (http://www.grisoft.com).   
   Version: 6.0.818 / Virus Database: 556 - Release Date: 12/17/2004   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca