Possible Duplicate:
Random number generator only generating one random number
In vb.net I am using this function to get random numbers:
Private Function GetRandom(ByVal Min As Integer, ByVal Max As Integer) As Integer
Dim Generator As System.Random = New System.Random()
Return Generator.Next(Min, Max)
End Function
I am calling the GetRandom function several times from another function which looks like this (simplified):
Public Sub GetRandomPerson()
Dim Gender as integer
Dim Zip as integer
Gender = GetRandom(1,3)
Zip = GetRandom(10000, 99999)
' Here I save the random person to DB
End Sub
And then I have this
For i As Integer = 1 to 10000
GetRandomPerson()
Next
My problem is that there seems to be a dependency on calls to GetRandom, it seems that if Gender is 1 then Zip will never be higher than a certain value (around 5000) and if Gender is 2 then Zip will always be higher than a certain value (around 5000).
Why is that, what am I missing?