Re: Dir command in VB

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Ken Halter (Ken_Halter_at_Use_Sparingly_Hotmail.com)
Date: 09/08/04


Date: Wed, 08 Sep 2004 15:07:42 -0700

Scott M. wrote:
> I want to be able to sort my Dir listings from within VB6. I presently use a
> command like
>
> sFilename = Dir(App.Path + "\Images\" + "*.bmp")
>
> to build a list of bmp files but VB generates the list in random order. Is
> there any way to sort by name or date as I could in DOS?
>
> Scott

No support for sorted returns from Dir.

Probably the easiest way to sort that list is.... set up an invisible
ListBox that has its Sorted property = True. Load that ListBox with the
returns from Dir and, when ready to parse, get the info from the ListBox.

btw... you should be using "&" to concatenate strings... not "+" so..

> sFilename = Dir(App.Path & "\Images\" & "*.bmp")

-- 
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep all discussions in the groups..

Quantcast