|
-
September 16th, 2000, 11:06 PM
#1
Random Numbers
heres the code:
private Sub Form_Load()
Label1.Caption = Int(Rnd * 10)
End Sub
Why is it that everytime that you load that load, label1 always = 7 or the same number, I want to randomly generate numbers!!
http://visualblind.tsx.org
-
September 16th, 2000, 11:55 PM
#2
Re: Random Numbers
from msdn
Before calling Rnd, use the Randomize statement without an argument to initialize the random-number generator with a seed based on the system timer.
David Paulson
-
September 17th, 2000, 12:54 AM
#3
Re: Random Numbers
I've tried that, it still doesn't work
http://visualblind.tsx.org
-
September 17th, 2000, 10:26 AM
#4
Re: Random Numbers
Try this with a small project. Add a label an a command button to the form. Paste this code.
private Sub Command1_Click()
Label1.Caption = Int(Rnd * 10)
End Sub
private Sub Form_Load()
Randomize
End Sub
David Paulson
-
September 17th, 2000, 11:27 AM
#5
Re: Random Numbers
no, you guys arent getting the picture, i need it on form_load nothing else
http://visualblind.tsx.org
-
September 18th, 2000, 05:09 PM
#6
Re: Random Numbers
I tried
option Explicit
private Sub Form_Load()
Randomize
Label1.Caption = Int(Rnd() * 10)
End Sub
on a simple form with a single default-named label, and it worked fine. Both from the development environment and compiled into an exe.
Does it work differently on your system?
(For more information about random number generation, see Knuth, Vol III I believe)
Dave Straayer
Varatouch, Inc.
David H. Straayer
-
September 18th, 2000, 07:35 PM
#7
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
|