0

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.

3
Contributors
2
Replies
19
Views
3 Years
Discussion Span
Last Post by velota27
0

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??

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.