Randomize Statement

Generates a repeatable sequence of random numbers in a specified range. Not available in expressions.

Syntax

Randomize (expression)

expression evaluates to a number, n. The range that the random number is selected from is 0 through (n -1). For example, if n is 100, the random number is in the range 0 through 99. If no expression is supplied, or if expression is a null value, the internal time of day is used, and the sequence is different each time the program is run.

Remarks

Use the Rnd function instead of Randomize if you want to generate an unrepeatable random number sequence.

Example

This is an example of how a routine might use the Randomize statement to set the start seed for the Rnd function to generate a specific set of random numbers:

Randomize 1
For n = 1 To NumRecords
* Produce strings like "ID00", "ID01", "ID57", and so on
RandomId = "ID" : Fmt(Rnd(100), "R%2")
* ... do something with the generated Ids.
Next n