Computing.Net > Forums > Programming > Go through all items in a ListBox

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Go through all items in a ListBox

Reply to Message Icon

Name: Doug52392
Date: August 25, 2006 at 13:47:44 Pacific
OS: Windows XP w/ SP2
CPU/Ram: Pentium 4/256Mb
Product: Toshiba Satellite
Comment:

Hi, I have been having a problem with a program I am devoloping with Visual Studio 2005 Express. I have a TextBox, Button and a ListBox. the user types text into the TextBox, then clicks the button to add the text into the ListBox. But I cant seem to get the program to go through the contents of the ListBox and do something with each string in the ListBox. How do I solve this?



Sponsored Link
Ads by Google

Response Number 1
Name: StuartS
Date: August 25, 2006 at 16:39:47 Pacific
Reply:

You dont say which language you are using, C++, C# or Visual Basic.

However here it is in VB. You should be able to adapt it to the language you are using assuming the list box is called List1.

Dim ListCount As Integer
Dim a As Integer
Dim ListItem As String

ListCount = List1.ListCount - 1

For a = 0 To ListCount
ListItem = List1.List(a)
Next

Stuart


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Go through all items in a ListBox

Scrolling Through VB Listbox Items www.computing.net/answers/programming/scrolling-through-vb-listbox-items-/17236.html

swapping to items in a list www.computing.net/answers/programming/swapping-to-items-in-a-list/5912.html

File I/O counting number of words in a file www.computing.net/answers/programming/file-io-counting-number-of-words-in-a-file/20183.html