-
Oct 11th, 2000, 03:23 PM
#1
Thread Starter
Fanatic Member
Code:
Randomize
A = Rnd(9)
B = Rnd(9)
C = Rnd(9)
D = Rnd(9)
E = Rnd(9)
F = Rnd(9)
G = Rnd(9)
H = Rnd(9)
DoEvents
That's what I have and all it gives me is 0 and 1
Visual Basic 6.0
Visual C++ 5
Delphi 5
-
Oct 11th, 2000, 03:26 PM
#2
Fanatic Member
Code:
Randomize(now())
A = int(Rnd *9)+1
B = int(Rnd *9)+1
C = int(Rnd *9)+1
D = int(Rnd *9)+1
E = int(Rnd *9)+1
F = int(Rnd *9)+1
G = int(Rnd *9)+1
H = int(Rnd *9)+1
DoEvents
There ya go, hope that helps
-
Oct 11th, 2000, 03:29 PM
#3
Plain old Randomize will work for your first statement.
-
Oct 11th, 2000, 04:15 PM
#4
Fanatic Member
True true, I just like giving it a seed that isn't necessarily the same each time a random number is needed heh
-
Oct 11th, 2000, 04:28 PM
#5
Fanatic Member
Unless you're attached to your "A,B,C,etc."
You may find this code a little more efficient.
Code:
Dim iArray(7) As Integer
Dim iTemp As Integer
Randomize
For iTemp = LBound(iArray) To UBound(iArray)
iArray(iTemp) = Int(Rnd * 9) + 1
Next
All the best.
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
|