ok. i got a command button and a label. i click the command button. and it will pick a random number from 1 to 1000. and it will change label 1 caption to the number.
Printable View
ok. i got a command button and a label. i click the command button. and it will pick a random number from 1 to 1000. and it will change label 1 caption to the number.
------------------Code:Private Sub Command1_Click()
Randomize Timer
Label1 = Int(Rnd * 999) + 1
End Sub
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Function RandRange(byval Lower as Double, Byval Upper as Double, Optional MyInt as Boolean = True)
Randomize
Select Case MyInt
Case Is = True
RandRange = Int((rnd * (Upper - Lower)) + Lower)
Case Is = False
RandRange = (rnd * (Upper - Lower)) + Lower
End Select
End Function
the above is a function that i wrote for a fractal app.
Syntax is:
RandRange(Lower as double, Upper as double, MyInt as Boolean)
It picks a random number between LOWER and UPPER, if you specify MyInt as false, then it will return a nuber with a decimal: ie. 111343275882.6774439, or something, the default is true (always a whole number returned).
hope this is usefull to someone
------------------
Wossname,
Email me: [email protected] :)
Aaron, what would happen if you didn't put a Randomize Timer in it?
------------------
Tom Young, 14 Year Old
[email protected]
ICQ: 15743470 Add Me ICQ Me
AIM: TomY10
PERL, JavaScript and VB Programmer
hey- im not Aaron, but i can answer your question Compwiz...If you didnt put in randomize timer it would pick the same "random" number each time.Randomize Timer sets the "seed" value of the randomizer based on the time of day,so it will always be different.Hope to have helped,
Thnx for your time,
CarlosTheJackal
Kewl, thanx. I didn't mean to address the question to just Aaron, but he made the code so... thanx!
[This message has been edited by Compwiz (edited 11-28-1999).]