17-07-2008, 09:19 PM
seraphelic Wrote:Actualy... no, Int(6*0,9)+1 = 6Dragoons 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
I got that example from MSDN, so it actually can't be wrong...
But for any range:
Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
Also got it from MSDN.
I miss read the first example.