Rnd()

Top  Previous  Next

Rnd() - Generate a random number

Description

The Rnd() function generates a random number greater than zero but less than one.

Rnd(Number]

Before using Rnd() use the [id=90]Randomize[/id] statement to seed the random number generator.

Parameters
The optional number parameter determines how random numbers are generated and can have several values, see the table below:

 

< 0 Generates the same number every time, using number as the seed.

> 0 Generates the next random number in the sequence.

0 Generates the most recently generated number.

Null Generates the next random number in the sequence.

 

 

Note: The Rnd() function does not produce highly random numbers and should not be used in tasks requiring highly random numbers such as encryption.

Example

 

Dim MyNumber

Randomize

MyNumber = Rnd() 'returns random number