I'm using the following code to read filenames from a directory into a semi-colon delimited string, which I need to have in either date or name order. However, it seems that this method returns the filenames in some other order (I'm guessing, according to the file's physical location in the directory ???) Does anyone know how to return these filenames in a specific order? I haven't been able to find a reference to this in any of my books.
' ----------------------------------------------------------Public Sub CheckDirectory(mstrDirectory As String)
Dim Counter As Long, strFname As String, mstrFileList As String
Counter = 0
mstrFileList = ""
' specify only .jpg files to be read
strFname = Dir(mstrDirectory & "*.jpg"
' Step through directory
While Not strFname = ""
If strFname <> "." And strFname <> ".." Then
mstrFileList = mstrFileList & Chr(34) & mstrDirectory & strFname & Chr(34) & ";"
End If
' Read next filename
strFname = Dir
Wend
[sig][/sig]
' ----------------------------------------------------------Public Sub CheckDirectory(mstrDirectory As String)
Dim Counter As Long, strFname As String, mstrFileList As String
Counter = 0
mstrFileList = ""
' specify only .jpg files to be read
strFname = Dir(mstrDirectory & "*.jpg"
' Step through directory
While Not strFname = ""
If strFname <> "." And strFname <> ".." Then
mstrFileList = mstrFileList & Chr(34) & mstrDirectory & strFname & Chr(34) & ";"
End If
' Read next filename
strFname = Dir
Wend
[sig][/sig]