|
-
Jan 7th, 2009, 03:43 PM
#1
Thread Starter
New Member
[2008] Sorting listbox data from External source
I am trying to figure out a correct way to sort the listbox that is being populated by data from an exteranl hard drive. The DB's on the Hard drive are contained in folders with a naming format as follows (Jan94 - Dec08)
The issue is that on the HD all the folders(yrs) for Apr are listed together and then the rest listed the same way, just sorted based on 1st alpha character. The format I want to show in the list box is as follows:
Jan94
Dec94
.
.
Jan08
Dec08
Jan09
Can anyone offer a solution or direction on how this could be achieved.
I've searched the forums and haven't seen anything that may offer a direction. Looked at MSDN and could't find a solution, maybe looking for the wrong thing.
Any ideas would be appreciated.
VB Newbie
-
Jan 7th, 2009, 04:23 PM
#2
Re: [2008] Sorting listbox data from External source
This is a small example you could use to sort the dates, obviously you will need to fill the list first with the folder names by using io.directory.getdirectories.
Code:
Dim DateList As New List(Of String)
DateList.Add("May76")
DateList.Add("Nov08")
DateList.Add("Apr07")
DateList.Add("Jan04")
DateList.Add("Jan08")
DateList.Add("Jun94")
DateList.Add("Jan09")
DateList.Add("Jan94")
DateList.Add("Dec94")
Dim SortList = From S In DateList _
Order By DateValue(S)
ListBox1.Items.AddRange(SortList.ToArray)
Casey.
-
Jan 7th, 2009, 05:14 PM
#3
Thread Starter
New Member
Re: [2008] Sorting listbox data from External source
Casey,
Thanks for the follow-up. Since there will be new DB's added on a monthly basis going forward, your solution appears to require me to come back and add in each new month, I was hoping for something that wouldn't require constant maintence.
Thanks
-
Jan 8th, 2009, 11:36 AM
#4
Re: [2008] Sorting listbox data from External source
 Originally Posted by Daniel1313
Casey,
Thanks for the follow-up. Since there will be new DB's added on a monthly basis going forward, your solution appears to require me to come back and add in each new month, I was hoping for something that wouldn't require constant maintence.
Thanks 
Not so. As Casey said, her code is just an example. In the real world you will populate the List by calling Directory.GetDirectories. That will get the current list of folder names whatever they happen to be.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|