Rnd
Syntax
Rnd ( [ Min [ , Max ] )
Computes a pseudo-random floating point number.
- If no parameters is specified, returns a pseudo-random number in the interval [ 0 , 1 [.
- If the one parameter is specified, returns a pseudo-random in the interval [ 0 , Min [.
- If the two parameters are specified, returns a pseudo-random in the interval [ Min , Max [.
Note that the higher born of the interval is never returned.
Example
' Between 0 and 1
PRINT Rnd
0.019539254718
Example
' Between 0 and 2
PRINT Rnd(2)
0.040205506608
Example
' Between Pi and Pi*2
PRINT Rnd(Pi, Pi(2))
3.204108046818
Example
STATIC PUBLIC SUB Main()
DIM Dice AS Integer
Randomize
Dice = Int(Rnd(1, 7))
'Throws the dice between 1 and 6
PRINT "You threw a " & dice
END
See also
Random Numbers Functions