08-30-2003, 12:50 AM
Quote:that's why he has INT(RND *50) + 1
Well removing the "INT" and you can get 500+ numbers without
repeating or overrule the "highest value limit"
/post]
i need some help
|
08-30-2003, 12:50 AM
Quote:that's why he has INT(RND *50) + 1 Well removing the "INT" and you can get 500+ numbers without repeating or overrule the "highest value limit"
/post]
09-01-2003, 12:26 PM
I think he meant that no identical number may follow each other, so that it is possible to get this: 1212121212121212. But no: 1221122112211. That would make it possible to get 56 random numbers out of 50.
09-02-2003, 02:45 AM
Quote:potato Wrote:pvera11 Wrote:im new to qb. my assignment is to create a lottery program that picks 56 random non repeating numbers from 1 to 50 inclusive. Come on guys! This is obviously a case of him pressing the "6" key but also accidentily pressing the "5" too, and not proofreading! Use your brains! Of course he means just "6".
09-02-2003, 03:39 AM
what if he means 5? or even 4 and has a fat finger? or maybe he means....
ammit potato!
09-02-2003, 03:47 AM
:roll: How many balls are usually in a lottery?
09-02-2003, 04:50 AM
There's pick-10, 5, and eight in my area. Six also, but I don't know anyone who plays that ;D
ammit potato!
09-03-2003, 07:47 PM
i ended up using some gosubs and for statements
cls start: dim num(6) gosub generate num(1) = rand for count = 2to6 gosub generate for count2 = 1 to (count -1) if rand=num(count2) then goto start end if next count2 num(count)=rand next count for count=1to6 print num(count); " "; next count print do if inkey$ = ch$(13) then goto start end if loop generate: upper=50 lower=1 rand=int(rnd*50)+1 return this codes alot better than the long one i had b4, only it kinda works slow...any suggestions? pvera11
09-03-2003, 08:26 PM
You could do it two ways. Generate random numbers and check all the other ones before it, or create a 50-number array filled with 1,2,3,4,etc. swap them around, and use the first 6 (or whatever you need).
Like this: (I'm just using the SHARED because you might want to use it in another sub, dunno. Doesn't hurt.) Code: DIM SHARED num%(1 TO 50) '(50) is (0 TO 50)..
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
09-05-2003, 08:10 PM
Oh, I forgot to initialize the values, so right now it's just swapping zeroes around. Silly me. Fixing it..
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."
Visit www.neobasic.net to see rubbish in all its finest.
09-06-2003, 03:14 AM
http://www.network54.com/Hide/Forum/thre...1062799714
Other goodies are found at http://www.network54.com/Hide/Index/10167 Mac |
« Next Oldest | Next Newest »
|