ArrayList to ListBox
Hello everyone i am getting input from the user in the form of an inputbox. The inputbox then dumps the information into an arrayList which then i want my Listbox to be populated by the items within the arrayList.
so...
userName = InputBox -> arrayList.add(userName) - > Listbox.items.add(arrayList)
Here is some of my code.
userName = InputBox("Enter Name: ")
Dim users As ArrayList = New ArrayList()
users.Add(userName)
For i As Integer = 0 To users.Count
<strong>termListBox.Items.Add(users.Item(i))</strong>
Next i
It gives me the error at the bold highlighted text. Any ideas?
jhonnyboy
Junior Poster in Training
97 posts since Jul 2008
Reputation Points: 11
Solved Threads: 0
What is the error message?
martonx
Junior Poster in Training
51 posts since May 2008
Reputation Points: 10
Solved Threads: 8
It said something about out of bounds. Does the syntax look right?
jhonnyboy
Junior Poster in Training
97 posts since Jul 2008
Reputation Points: 11
Solved Threads: 0
That worked thanks :) I have another question. How can i load a form from another form? I tried form.show but the form came up and quit after a couple of seconds.
jhonnyboy
Junior Poster in Training
97 posts since Jul 2008
Reputation Points: 11
Solved Threads: 0
What is your code for new form?
Perhaps you close the new form after show.
You can try form.showdialog too.
martonx
Junior Poster in Training
51 posts since May 2008
Reputation Points: 10
Solved Threads: 8