ArrayList to ListBox

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2008
Posts: 86
Reputation: jhonnyboy is an unknown quantity at this point 
Solved Threads: 0
jhonnyboy jhonnyboy is offline Offline
Junior Poster in Training

ArrayList to ListBox

 
0
  #1
Mar 9th, 2009
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?
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 51
Reputation: martonx is an unknown quantity at this point 
Solved Threads: 8
martonx martonx is offline Offline
Junior Poster in Training

Re: ArrayList to ListBox

 
0
  #2
Mar 9th, 2009
What is the error message?
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 86
Reputation: jhonnyboy is an unknown quantity at this point 
Solved Threads: 0
jhonnyboy jhonnyboy is offline Offline
Junior Poster in Training

Re: ArrayList to ListBox

 
0
  #3
Mar 9th, 2009
It said something about out of bounds. Does the syntax look right?
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

Re: ArrayList to ListBox

 
0
  #4
Mar 9th, 2009
try:
  1. For i As Integer = 0 To users.Count -1
Wayne

It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 86
Reputation: jhonnyboy is an unknown quantity at this point 
Solved Threads: 0
jhonnyboy jhonnyboy is offline Offline
Junior Poster in Training

Re: ArrayList to ListBox

 
0
  #5
Mar 10th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 51
Reputation: martonx is an unknown quantity at this point 
Solved Threads: 8
martonx martonx is offline Offline
Junior Poster in Training

Re: ArrayList to ListBox

 
0
  #6
Mar 10th, 2009
What is your code for new form?
Perhaps you close the new form after show.
You can try form.showdialog too.
Reply With Quote Quick reply to this message  
Join Date: Dec 2002
Posts: 461
Reputation: waynespangler is on a distinguished road 
Solved Threads: 56
waynespangler waynespangler is offline Offline
Posting Pro in Training

Re: ArrayList to ListBox

 
0
  #7
Mar 10th, 2009
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.
Wayne

It is hard to understand how a cemetery can raise its burial rates and blame it on the cost of living.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC