I want to pick some uniq numbers from a list of numbers randomly list of numbers:
dim firstlist() = [1,2,3,6,7,9,12,16]
I want to pick some uniq numbers randomly from this list
[2,6,16]
I want to pick some uniq numbers from a list of numbers randomly list of numbers:
dim firstlist() = [1,2,3,6,7,9,12,16]
I want to pick some uniq numbers randomly from this list
[2,6,16]
like this?
Dim firstlist() = {1, 2, 3, 6, 7, 9, 12, 16}
Dim seclist As New Collection
Dim rnd As New Random
Debug.WriteLine("__")
Dim i As Integer = 1
While i <= 3
Dim j As Integer = CInt(rnd.Next(0, firstlist.Length - 1))
If Not seclist.Contains(j) Then
seclist.Add(firstlist(j), j)
Debug.WriteLine(CStr(firstlist(j)))
i += 1
End If
End While
'seclist now contains 3 values (data) and the indices (key)
Dim firstlist = {1, 2, 3, 6, 7, 9, 12, 16}
dim secondlist as new list(of integer)
dim rand as new random()
while not secondlist.count = 3
secondlist.add(firstlist(rand.next(firstlist.count-1)))
end while