title: random and shuffle questions vb
body: <p>i'm puzzled in the logic of shuffling the questions that i'll display from my database.
  my current code displays random questions to the textbox but it also display empty and duplicate entries. </p>
  
  <pre><code>    Dim r As MySqlDataReader
      Dim i As Integer = 0
      Dim temp() As Integer = {}
  
  
      Dim txtQ() As TextBox = {txtQ1, txtQ2, txtQ3, txtQ4, txtQ5, txtQ6, txtQ7, txtQ8, txtQ9, txtQ10}
      Dim cbA() As CheckedListBox = {cbA1, cbA2, cbA3, cbA4, cbA5, cbA6, cbA7, cbA8, cbA9, cbA10}
  
      con.Open()
      cmd = New MySqlCommand("select * from tbexam", con)
      r = cmd.ExecuteReader
  
  
      While r.Read
          If i &lt;= 9 Then
              Randomize()
              Dim j As Integer = CInt(Int(9 * Rnd()))
  
              txtQ(j).Text = r.GetString("exam_question")
              cbA(j).Items.Clear()
              cbA(j).Items.Add("a) " &amp; r.GetString("exam_ans_a"))
              cbA(j).Items.Add("b) " &amp; r.GetString("exam_ans_b"))
              cbA(j).Items.Add("c) " &amp; r.GetString("exam_ans_c"))
              cbA(j).Items.Add("d) " &amp; r.GetString("exam_ans_d"))
  
  
              i = i + 1
          End If
      End While
  </code></pre>