T
tshad
I am trying to create some random numbers to create an ID and am having
problems with getting the same number over and over.
I have a function:
Function RandomNumber(min as Integer, max as Integer) as integer
Dim random as Random = new Random()
RandomNumber = random.Next(min, max)
End Function
If I call this 3 times:
id = RandomNumber(0, 10))
id = RandomNumber(0, 10))
id = RandomNumber(0, 10))
I will get the same number each time.
I assume this is because it is based on the clock and uses the same seed if
call one after another. Is there a good way around this?
Thanks,
Tom
problems with getting the same number over and over.
I have a function:
Function RandomNumber(min as Integer, max as Integer) as integer
Dim random as Random = new Random()
RandomNumber = random.Next(min, max)
End Function
If I call this 3 times:
id = RandomNumber(0, 10))
id = RandomNumber(0, 10))
id = RandomNumber(0, 10))
I will get the same number each time.
I assume this is because it is based on the clock and uses the same seed if
call one after another. Is there a good way around this?
Thanks,
Tom