title: Error in VB: An unhandled exception of type 'System.IndexOutOfRangeException' occurred in language.exe
body: <p>An unhandled exception of type 'System.IndexOutOfRangeException' occurred in language.exe</p>
  
  <p>Additional information: Index was outside the bounds of the array.</p>
  
  <p>here is the code where the error is:</p>
  
  <pre><code>Private Sub RichTextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles         RichTextBox1.KeyDown
      Dim i As Integer = 0
      If e.KeyCode = Keys.Enter Then
          i = i + 1
          Dim t As String = RichTextBox1.Lines(i).ToString()
          ListBox1.Items.Add(t)
      End If
  End Sub
  </code></pre>