O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Randomize Procedure

Class

Microsoft.VisualBasic.VBMath

Syntax

Randomize([number])
number (optional; Object or any valid numeric expression)

A number used to initialize the random-number generator

Description

Initializes the random-number generator

Rules at a Glance

  • Randomize uses number as a new seed value to initialize the random-number generator used by the Rnd function. The seed value is an initial value that is used to generate a sequence of pseudorandom numbers.

  • If you do not pass number to the Randomize procedure, the value of the system timer will be used as the new seed value.

  • Repeatedly passing the same number to Randomize does not cause Rnd to repeat the same sequence of random numbers.

Programming Tips and Gotchas

If you need to repeat a sequence of random numbers, you should call the Rnd function with a negative number as an argument immediately prior to using Randomize with any numeric argument.

See Also

Rnd Function

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required