i am trying to put the contents of a listbox into an array using listcount so i can sort and manipulate the data in the listbox using linq. Everytime I try to use listcount it errors and tells me that listcount is not a member of systems.windows.forms.listbox It also gives this error or list. Here is the for loop i am trying to use to put the data into the array.

 For i = 0 To displayListBox1.Listcount - 1
            sorting(i) = displayListBox1.list(i)
        Next

i dim'd i as an integer and sorting() as a string early in the program as class level variables. displayListBox1 is the name of the listbx containing the data I need to use in my LINQ inquiry. thank you.

Recommended Answers

All 3 Replies

Should not this line
sorting(i) = displayListBox1.list(i)
be reversed ?

no that didnt work it still get same error

displayListBox1 is the name of the listbx containing the data I need to use in my LINQ inquiry. thank you.

If you want to use LINQ, I guess there is no need to store the value off the Listbox in array.

Dim _Linq As IEnumerable = From _ListBoxItems In Me.ListBox1.Items _
                           Select _ListBoxItems
For Each _Item In _Linq
    Debug.Print(_Item)
Next
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.