943,522 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 8975
  • VB.NET RSS
Mar 9th, 2009
0

ArrayList to ListBox

Expand Post »
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

            termListBox.Items.Add(users.Item(i))
        Next i

It gives me the error at the bold highlighted text. Any ideas?
Similar Threads
Reputation Points: 11
Solved Threads: 0
Junior Poster in Training
jhonnyboy is offline Offline
97 posts
since Jul 2008
Mar 9th, 2009
0

Re: ArrayList to ListBox

What is the error message?
Reputation Points: 10
Solved Threads: 8
Junior Poster in Training
martonx is offline Offline
51 posts
since May 2008
Mar 9th, 2009
0

Re: ArrayList to ListBox

It said something about out of bounds. Does the syntax look right?
Reputation Points: 11
Solved Threads: 0
Junior Poster in Training
jhonnyboy is offline Offline
97 posts
since Jul 2008
Mar 9th, 2009
0

Re: ArrayList to ListBox

try:
VB.NET Syntax (Toggle Plain Text)
  1. For i As Integer = 0 To users.Count -1
Reputation Points: 84
Solved Threads: 58
Posting Pro in Training
waynespangler is offline Offline
461 posts
since Dec 2002
Mar 10th, 2009
0

Re: ArrayList to ListBox

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.
Reputation Points: 11
Solved Threads: 0
Junior Poster in Training
jhonnyboy is offline Offline
97 posts
since Jul 2008
Mar 10th, 2009
0

Re: ArrayList to ListBox

What is your code for new form?
Perhaps you close the new form after show.
You can try form.showdialog too.
Reputation Points: 10
Solved Threads: 8
Junior Poster in Training
martonx is offline Offline
51 posts
since May 2008
Mar 10th, 2009
0

Re: ArrayList to ListBox

Double click on the My Project. On the left hand side toward the bottom in the Shut Down Mode select "After last form closes".
If you don't then when you close the startup form the program ends.
Reputation Points: 84
Solved Threads: 58
Posting Pro in Training
waynespangler is offline Offline
461 posts
since Dec 2002

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: grid view problem
Next Thread in VB.NET Forum Timeline: Need help with countdown timer for a poker clock





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC