From Xojo Documentation

You are currently browsing the old Xojo documentation site. Please visit the new Xojo documentation site!

Class (inherits from Object)

Used to generate random numbers.

Gaussian Number
InRange RandomizeSeed


Use System.Random to create an instance of this class.

The Random class supersedes the Rnd function. It performs the same functions and more.

A custom random number generator is used. For best results, you should only create a single instance of Random per app.

The Random class's seed is used to initialize the pseudo-random number generator's algorithm so that you can always get the same stream of numbers from the same seed. However, this is not an endian-independent operation. If you set the seed on a big-endian machine to the same value that you used on a little-endian machine, you will get two different streams of pseudo-random numbers.

Sample Code

Use System.Random to get an instance of the class:

Var i As Integer = System.Random.InRange(0, 1000)
MessageBox("The random number is: " + i.ToString)

See Also

Rnd, System.Random functions