How to randomize an array of integers

  • Thread starter Thread starter Robert Homes
  • Start date Start date
R

Robert Homes

Guest
Can someone tell me what's wrong with this?

Private Sub RandomizeArray(ByVal items() As Integer)
Dim rnd As New Random
Dim max As Integer = items.Length - 1
Dim Temp, j As Integer
For i As Integer = 0 To max - 1
' Pick an item
j = rnd.Next(i, max + 1)

' Swap them.
Temp = items(i)
items(i) = items(j)
items(j) = Temp
Next i
End Sub




Robert Homes

Continue reading...
 
Back
Top