Programmer_Jpk
Newcomer
- Joined
- Jun 4, 2009
- Messages
- 4
i was wondering how people go about getting Unique Number Array's? cause a lot of people do it very differently , seen people with 100 lines of code, others with 10.. my way lately has been using HashTables
So Yeah o.o, just wondering how people go about their random values.. and weather or not there is more simpler stuff i could steal :]
Code:
Dim a As Integer ' Just a Counting Value
Dim RNS As Integer = 100 ' Random Numbers i'm just using 100, cause i can
Dim RandomValues As New Hashtable ' Hash Table, Of Course o.o
Dim RandValue As Integer ' Random Number
While a <> RNS
Randomize()
RandValue = Int((RNS - 0 + 1) * Rnd()) + 0 ' highest - Lowest + 1 ect..
While RandomValues.ContainsValue(RandValue) ' If Hastable Contains The Value, Go nuts till it gets it
RandValue = Int((RNS - 0 + 1) * Rnd()) + 0
End While
RandomValues(a) = RandValue if it got it, set it..
a += 1 ' Repeat
End While