8 replies
by lo
Hi - Several ways you can do this. I took a quick look in VB6 for Sort but didn't find anything that looked like it would do the trick quickly.
You can create an hidden listbox, set the property for sorted (reverse it that is possible, been a while), load the file to the list box. Then take each entry (if reverse sort, 1st entry is 1st, if not, process backwards (last, last-1, etc.).
You can probably activate a DOS session and pass the file to SORT (from a DOS prompt HELP SORT for specifics on sort). Not sure about specifics of starting a DOS session from VB, but I know it's possible.
You can create an array, load the file to the array and sort (can sort as you load if you want).
There are probably other solutions. Check in VB Help, for other possibilities.
by anamenow
by donq
Just query your data:
SELECT: list the table.field compinations you want
FROM: name your data source
WHERE: list any constraines or links
ORDER BY: enter your sorting instructions
Look under SQL statements dor on-line help.
by anamenow
by peyison
The listbox method in Answer 1 is not bad if you have a small list. The best solution would be to write your own routine in VB. There are many different ways to sort a list, the best choice depends on the number of items in the list, and the condition of the list. In your case, since the list is sorted to begin with, before you insert new items, your best bet may be not a sorting solution at all. It may be best to insert the items in the already sorted list as you add them. So what you need is a search routine (so you can search for the position in the list to add the new item).
The fastest would be a binary search, but you could also just start from the top of the list and check every item until you find the position where the new item should go.
You will also need to know (or learn) a little about arrays and linked lists.
So - if you're interesed in learning a few things about VB, I'd recommend the binary search and insert method (or insertion sort). I'd be happy to help with this. If you're just looking for a quick hack to get the job done, use the sorted list box.
Hope this helps.
by anamenow
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending