Skip to content

Instantly share code, notes, and snippets.

@aloon aloon/gist:4771179
Last active Dec 12, 2015

Embed
What would you like to do?
get UniqueRandomNumbers
Private Shared Function UniqueRandomNumbers(NumAleatories As Integer, elements As Integer) As List(Of Integer)
Dim aleatorios As New List(Of Integer)
If elements > 0 Then
Dim temp As List(Of Integer) = Enumerable.Range(0, elements)
If NumAleatories > elements Then
aleatorios = temp.OrderBy(Function(a) Guid.NewGuid())
Else
Dim r As New Random(DateTime.Now.Millisecond)
For i As Integer = 0 To NumAleatories - 1
Dim start As Integer = r.Next(0, temp.Count - 1)
aleatorios.Add(temp(start))
temp.RemoveAt(start)
Next
End If
End If
Return aleatorios
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.