Rnd
Float = Rnd ( [ Min [ , Max ] ] )
Compute a pseudo-random floating point number.
-
If no parameter is specified, returns a pseudo-random number in the interval [
0
, 1
[.
-
If only one parameter is specified, returns a pseudo-random in the interval [
0
, Min [.
-
If both parameters are specified, returns a pseudo-random in the interval [ Min , Max [.
The higher born of the interval is never returned. This is why the interval is ended by a right square bracket!
The algorithm producing the pseudo-random numbers is a twisted generalized feedback shift register.
Examples
' Between 0 and 1
Print Rnd
' Between 0 and 2
Print Rnd(2)
' Between Pi and Pi*2
Print Rnd(Pi, Pi(2))
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