J
juvi
Hello,
I have a code in vb.net to generate unique integer values from 1 to 52 to a
list, but it generates every time the same values in the same order. How to
correct this ? thx juvi
Dim shuffle(52) As Integer
Dim rnd As New Random(52)
Sub Generate()
Dim x, mix, temp As Integer
For x = 1 To 52 'assign sequential values to the array
shuffle(x) = x
Next x
For x = 1 To 52 'swap array positions randomly
mix = rnd.Next(1, 53)
temp = shuffle(mix)
shuffle(mix) = shuffle(x)
shuffle(x) = temp
Next x
End Sub
I have a code in vb.net to generate unique integer values from 1 to 52 to a
list, but it generates every time the same values in the same order. How to
correct this ? thx juvi
Dim shuffle(52) As Integer
Dim rnd As New Random(52)
Sub Generate()
Dim x, mix, temp As Integer
For x = 1 To 52 'assign sequential values to the array
shuffle(x) = x
Next x
For x = 1 To 52 'swap array positions randomly
mix = rnd.Next(1, 53)
temp = shuffle(mix)
shuffle(mix) = shuffle(x)
shuffle(x) = temp
Next x
End Sub