The following example declares a new instance of the Random class and then uses the method
.Next to generate the next number in the sequence of pseudo-random numbers.
Dim rnd As New Random Dim x As Integer x = rnd.Next
The last line above will generate the next pseudo-random number and assign it to
x. This number will be in the range of 0 - 2147483647. However, you can also specify the range of numbers to be generated as in the example below.
x = rnd.Next(15, 200)
Please note however, that using these parameters, range of numbers will be between 15 or above and 199 or below.
You can also generate floating point numbers of the type Double by using
Dim rnd As New Random Dim y As Double y = rnd.NextDouble()
You cannot however specify a range for this. It will always be in the range of 0.0 to less than 1.0.