scbs29
2012-07-15 20:27:38 UTC
Hello all
Can anyone advise me of a sort array for the following.
I have files in a folder, the names of whic I pick up within my
program using the Dir() function, eg
Dim intFiles As Integer
Dim strFile As String
intFiles = 0
strFile = Dir(strFolder)
Do While strFile <> vbNullString
If strFile <> "." And strFile <> ".." Then
intFiles = intFiles + 1
ReDim Preserve strFileNames(intFiles)
strFileNames(intFiles - 1) = strFolder &
strFile
End If
strFile = Dir
Loop
In explorer the filenames are listed as
box1
box1_1
box2
box2_1
box3
box3_1
.
.
.
box9
box9_1
box10
box10_1
box11
box11_1
etc
but when I retrieve and display the filenames they are listed as
box1
box10
box10_1
box11
box11_1
.
.
.
box19
box19_1
box1_1
box2
box20
box20_1
box2_1
How can I sort these names so that they are in the same order as sjown
in explorer ?
I have tried a lot of sort algorithms I have found through DuckDuckGo
but none of them do the job.
Can anyone help ?
Will I have to write my own sort algorithm ?
ANy advice gratefully received.
TIA
remove fred before emailing
Registered Linux User 490858
Can anyone advise me of a sort array for the following.
I have files in a folder, the names of whic I pick up within my
program using the Dir() function, eg
Dim intFiles As Integer
Dim strFile As String
intFiles = 0
strFile = Dir(strFolder)
Do While strFile <> vbNullString
If strFile <> "." And strFile <> ".." Then
intFiles = intFiles + 1
ReDim Preserve strFileNames(intFiles)
strFileNames(intFiles - 1) = strFolder &
strFile
End If
strFile = Dir
Loop
In explorer the filenames are listed as
box1
box1_1
box2
box2_1
box3
box3_1
.
.
.
box9
box9_1
box10
box10_1
box11
box11_1
etc
but when I retrieve and display the filenames they are listed as
box1
box10
box10_1
box11
box11_1
.
.
.
box19
box19_1
box1_1
box2
box20
box20_1
box2_1
How can I sort these names so that they are in the same order as sjown
in explorer ?
I have tried a lot of sort algorithms I have found through DuckDuckGo
but none of them do the job.
Can anyone help ?
Will I have to write my own sort algorithm ?
ANy advice gratefully received.
TIA
remove fred before emailing
Registered Linux User 490858