title: Visual Basic Iterating Over a ListBox with an Event Listener
body: <p>I have a ListBox Containg a list of items,i am wondering how would i create a handler which can Iterate the ListBox whenever an event is happen.<br>
  I have the Following Code to read a file into a listbox.</p>
  
  <pre><code>Private Sub Load_File_To_ListBox(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Load_File_To_ListBox.Click
      Dim r As New IO.StreamReader("C:\Users\resu\Desktop\test.txt")
      While (r.Peek() &gt; -1)
          lb1.Items.Add(r.ReadLine)
      End While
      r.Close()
  End Sub
  </code></pre>
  
  <p>Here is my event handler code:</p>
  
  <pre><code>Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
      TextBox1.Text = " "
      TextBox1.Text &amp;= ListBox1.SelectedItems.Item(i).ToString
      i = i + 1
  End Sub
  </code></pre>
  
  <p><code>i</code> is declared  as a global variable to keep track of the next item In the <code>ListBox</code>.   What I want is to read the next item from the <code>Listbox</code> and put it into the <code>TextBox</code> whenever Button2 is Clicked. </p>
  
  <p>Kindly help me in modifying my code to make it work.  </p>