Hey Everyone, I'm stuck... I've got a 1-dimensional array from a text file that is displaying in a list box. I have buttons to sort ascending and descending but cannot seem to get them to work. My code for the array is

Dim name() As String = IO.File.ReadAllLines("Countries.txt")
lstCountries.Items.AddRange(name)

This code is successfully populating the listbox at launch. I've tried to pass this to the subs for the buttons when clicked are to sort and been unsuccessful so I have the original line in the subroutine as well. The code I've written to sort sub is:

            Dim name() As String = IO.File.ReadAllLines("Countries.txt")
            Dim sortdown = From var In name
                           Order By name Descending
            For Each var As String In sortdown
            Next
            lstCountries.Items.Clear()
            lstCountries.Items.AddRange(name)
End Sub

Its not working at all. It clears the listbox and repopulates the alphabetical list as originally placed in the box. I have made sure that the listbox sorting is turned off as well.
Any help would be greatly appreciated. I feel like I'm on the right track but missing something.

You want to sort items on listbox?
Try this :

lstCountries.Sorted = True

hi every one..i have encountered a system that needs a code for the list item on the list box to put to other listbox..can you help me how to do it??

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.