Random Number Generator in VB.NET
In some situations we have to generate Random numbers in our VB.NET applications for different purposes. In these situations we have to use Random Class for generating the Random numbers. The Random Class in VB.NET represents a pseudo-random number generator, a device that produces a sequence of numbers that meet certain statistical requirements for randomness.
Shared random As New Random()
The Next() method in Random class returns a nonnegative random number.
We can limit the generation of Random number by giving a specified range to Next() method.
The above code limit to generate the Random number within the range from 10 to 20.
To improve performance, create one Random object to generate many random numbers over time, instead of repeatedly creating a new Random objects to generate one random number. The following VB.NET program generate Random numbers within the specified rand from 10 to 20.