Rand

Sinds 3.6

Integer = Rand ( Min [ , Max ] )

Compute a pseudo-random integer number.

  • If one parameter is specified, returns a pseudo-random number in the interval [ 0 , Min ].

  • If both parameters are specified, returns a pseudo-random number in the interval [ Min , Max ].

Contrary to Rnd, the higher born of the interval can be returned.

Examples

' Between 0 and 2
Print Rand(2)
2

' Between 1 and 10
Print Rand(1, 10)
3

Public Sub Main()

  Dim Dice AS Integer

  Randomize

  Dice = Rand(1, 6)

  ' Throws the dice between 1 and 6
  Print "You threw a " & dice

End

See also