*MAFIA* Forums

*MAFIA* Forums

  • April 29, 2024, 03:33:26 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome back the Arcade! Play over 100+ games to get the high score and compete against other forum members.

http://www.mafiaowns.com/index.php?action=arcade;sa=list;sortby=a2z;

Author Topic: Generating Unique Random Numbers 1 - 20 VB6 prof.  (Read 1388 times)

Partyboy

  • Forum Member
  • Reputation: 681
  • Offline Offline
  • Posts: 1,065
    • View Profile
Generating Unique Random Numbers 1 - 20 VB6 prof.
« on: April 27, 2007, 07:23:31 PM »

Im trying to Generate 20 random unique numbers on 20 different labels, in Visual Basic 6.0 Professional.

I know how to get them random

Like so
Code: [Select]

Label1.Caption = Int(Rnd * 20)
Label2.Caption = Int(Rnd * 20)

so on

Label20.Caption = int(Rnd * 20)

Code: [Select]

Randomize


This will make it so each label will display a random number

But the thing is, is that i cannot have the numbers duplicate. I need to have each number be unique.
So label1.caption cannot = label5.caption

How can this be done.

I now i need an array and loop

So

Code: [Select]

For i = 1 to 20
                                    '<<<<< what goes here?
next


Thanks
Logged

*MAFIA* Bonehead

  • *MAFIA* Founder
  • Forum Member
  • Reputation: 2584
  • Offline Offline
  • Posts: 8,007
    • View Profile
    • *MAFIA*
Re: Generating Unique Random Numbers 1 - 20 VB6 prof.
« Reply #1 on: April 27, 2007, 07:24:58 PM »

Use the number scramble spell it does wonders!
Logged

Partyboy

  • Forum Member
  • Reputation: 681
  • Offline Offline
  • Posts: 1,065
    • View Profile
Re: Generating Unique Random Numbers 1 - 20 VB6 prof.
« Reply #2 on: April 27, 2007, 07:51:01 PM »

K heres a better way to explain. In my algebra class we are doing this simple quizes where you have 45 secs to answer 1squared all the way up to 20 squared so you have to have them memorized. I do but i thought this would be fun to make.
So i made a dialog that had you click start. Then there are 20 labels and 20 texts the labels then have numbers on them that are radomly generated. then you right the correct answer so if label4 says "14" you right in the text 190. Then when the 45 secs are up it disables everthing then tells you how many you got right. All of this i got but getting the numbers to come only once.... see  sometimes there will be two 15's or 17's or something and i need each label to have its own.  How can this be done. here is what i have so far. It only counts from 5 right now.
Logged
 

Page created in 0.032 seconds with 31 queries.