|
-
Nov 26th, 1999, 12:11 PM
#1
Thread Starter
Junior Member
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.
-
Nov 26th, 1999, 12:29 PM
#2
Code:
Private Sub Command1_Click()
Randomize Timer
Label1 = Int(Rnd * 999) + 1
End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
Nov 26th, 1999, 05:28 PM
#3
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] 
-
Nov 27th, 1999, 04:33 AM
#4
Hyperactive Member
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
-
Nov 27th, 1999, 09:48 AM
#5
Member
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
-
Nov 27th, 1999, 10:37 PM
#6
Hyperactive Member
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).]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|