Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Textbox lines to listbox? "Index was outside the bounds of the arr

$
0
0
Hi, I'm making a program and a small part of it includes a multi-line textbox and a listbox.
After entering text into the textbox the user would click a button and each line in the textbox will become an item in the listbox.

Here's the code I have:

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim ii As Integer
        Dim a As String = ""
        ii = TextBox1.Lines.Count()
        ListBox1.Items.Clear()
        For i As Integer = 1 To ii
            a = TextBox1.Lines(i)
            ListBox1.Items.Add(a)
        Next i
End Sub



When I run it I get the following error "Index was outside the bounds of the array."

I'd very much apritiate it if someone could help me

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>