Rnd

Rnd([pNumber])

The Rnd function returns a random number between 0 and 1. The optional parameter pNumber is totally ignored.

The returned value can be 0, but will never be 1. To get a number in a diffent range, you must multiply and add values

SendDebug Rnd 'Prints a random number below 1
SendDebug Rnd(10) 'Prints a random number below 1

Function CreateRandomNumber(pMinValue As Long, pMaxValue As Long) As Long
   'Both pMinValue and pMaxValue could be part of the result
   Return Int(Rnd * (pMaxValue - pMinValue + 1)) + pMinValue
End Function

SendDebug CreateRandomNumber(1, 6) 'Rolls the dice

See also: