Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random Function?
#4
Dragoons Master Wrote:
Code:
Dim MyValue
MyValue = Int((6 * Rnd) + 1)   ' Generate random value between 1 and 6.

That wouldn't work. if Rnd turned out to be .9, then MyValue would equal 7.

Here's a working function.
Function Rand(ByVal Low As Long, ByVal High As Long) As Long
Rand = Int((High - Low + 1) * Rnd) + Low
End Function
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)