


So if you write the following code, you're going to get the same number a bunch of times in a row: Dim randoms(1000) As Integerįor i As Integer = 0 to randoms.Length - 1 On most systems, this has limited granularity - somewhere in the vicinity of 20 ms.

The reason is that the constructor for the Random class provides a default seed based on the system's clock. As has been pointed out many times, the suggestion to write code like this is problematic: Public Function GetRandom(ByVal Min As Integer, ByVal Max As Integer) As Integerĭim Generator As System.Random = New System.Random()
