title: Random numbers in array without any duplicates
body: <p>I'm trying to randomize an array from numbers 0 to 51 using loops but I just cannot seem to pull it off. My idea was that</p>
  
  <ol>
  <li>Generate a Random Number</li>
  <li>Check if this random number has been used by storing the previous in an array</li>
  <li>If this random number has been used, generate new random number until it is not a duplicate</li>
  <li>If it's not a duplicate, store it</li>
  </ol>
  
  <p>My attempt:</p>
  
  <pre><code>    Dim list(51) As Integer
      Dim templist(51) As Integer
  
      For i As Integer = 0 To 51 Step 1
          list(i) = i
      Next i
  
      Do While counter &lt;= 51
          p = rand.Next(0, 52)
          templist(counter) = p
          For n As Integer = 0 To 51 Step 1
              p = rand.Next(0, 52)
              If templist(n) = p Then
                  Do While templist(n) = p
                      p = rand.Next(0, 52)
                  Loop
                  templist(n) = p
              Else
                  templist(n) = p
              End If
  
          Next
  
          counter += 1
      Loop
  
      For n As Integer = 0 To 51 Step 1
          ListBox1.Items.Add(templist(n))
      Next
  </code></pre>