I have an array of integers like these;
dim x as integer()={10,9,4,7,6,8,3}.
Now I want to pick a random number from it,how can I do this in visual basic?Thanks in advance…
I have an array of integers like these; dim x as integer()={10,9,4,7,6,8,3}. Now I
Share
First you need a random generator:
Then you pick a random number that represents an index into the array:
Then you get the value from the array:
Or the two last as a single statement:
Now, if you also want to remove the number that you picked from the array, you shouldn’t use an array in the first place. You should use a
List(Of Integer)as that is designed to be dynamic in size.