
-----------------------------------
Darkmantis
Thu Dec 08, 2005 6:11 pm

How do you create random integers in VB 6.0?
-----------------------------------
I am stuck on a game I am making because I have no clue how to make random integers. In turing it is Randint i: 1..6 but I don't know how it is in VB 6.0.

-----------------------------------
Tony
Thu Dec 08, 2005 8:25 pm


-----------------------------------
Rnd returns a random float.

-----------------------------------
Darkmantis
Fri Dec 09, 2005 6:57 am


-----------------------------------
Rnd 6
If Rnd = 1 Or 4 Then
creature1.Left = creature1.Left + 300
End If
If Rnd = 2 Or 5 Then
creature1.Left = creature1.Left - 300
End If
If Rnd = 3 Or 6 Then
creature1.Left = creature1.Left
End If

im trying this code but its not working.

-----------------------------------
Tony
Fri Dec 09, 2005 9:35 am


-----------------------------------
What values does Rnd return?

-----------------------------------
pavol
Fri Dec 09, 2005 10:18 am


-----------------------------------
anytime i've used the rnd function i store the randomized number in a variable like so: number = Int(Rnd * 6) and then check the number variable for the value
If number = 5 then
'whatever
End If

-----------------------------------
Tony
Fri Dec 09, 2005 10:59 am


-----------------------------------
Should be pointed out that Int(Rnd * 6) will return numbers from 0 to 5

-----------------------------------
pavol
Fri Dec 09, 2005 11:18 am


-----------------------------------
if you don't want the zero then just add Int(Rnd *6)+1

-----------------------------------
Darkmantis
Sat Dec 10, 2005 10:28 am


-----------------------------------
ok thx a lot guys  :D
