dim a(12) asstringdim n as intger
dim r asnew random
dim f asboolean = FalseFor i = 1To12
n = r.Next(12) + 1
TextBox1.Text = CStr(n)
a(i) = CStr(n)
For j = 1To i - 1While f = False
n = r.Next(12) + 1If n = CStr(a(j)) Then
a(i) = CStr(n)
Else
f = TrueEndIfEndWhileNextNext

I'm not really sure about what you wanna do? So maybe you can be a little more explicit. However, If you are trying to generate a random array where elements cannot be repeated here is a good algorithm.

Suppose N is the length of your array, what you really want is a permutation of the first N positive integers, do the following:

1- Fill the array such that a(i) = i
2- for i = 1 to n do
j = random(n)
swap(a(i),a(j))

Nice one, take my five for that, but in your solution there is still the restriction that the possible numbers run from 1 to n. His question aims more into the direction to choose random integers and repeat if an integer was already chosen. But that's only the way I read it.