lang • rand

Rand

Since 3.6

Integer = Rand ( Min [ , Max ] )

Compute a pseudo-random integer number.

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