Fix Sort order of a combobox in vb6

Have a sorted comobox of filenames that the sorder is not right if a 0 is not added to numbers under 10 Eg;
1-3-2016.rtf change to 01-03-2016.rtf
Yr1-10-2016.rtf change to Yr01-10-2016.rtf
Yr7-4-2016.rtf change to Yr07-04-2016.rtf

Example file names
I have code the saves the files in the correct format, but it seems some slip by
how can this be corrected ?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
How difficult would it be to create the names so that they contained the missing zeros?

If you like I could provide code that would rename all the existing ones.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
isnoend2001Author Commented:
Yes rename the files
 I could run the code before the filenames were loaded.
Martin LissOlder than dirtCommented:
This should rename them all. You will of course need to change the file path (in five places).

Dim strFile As String
Dim intPos As Integer

strFile = Dir("C:\temp\*.rtf")
Do While strFile <> Empty
    intPos = InStr(1, strFile, "-")
    Select Case intPos
        Case 2
            Name "C:\temp\" & strFile As "C:\temp\0" & strFile
        Case 4
            Name "C:\temp\" & strFile As "C:\temp\" & Left$(strFile, 2) & "0" & Mid$(strFile, 3)
    End Select
    strFile = Dir()

Open in new window

isnoend2001Author Commented:
could that be added to this sub ? :
Private Sub ListFiles(strPath As String, Optional Extention As String)
'typical path C:\Program Files (x86)\Microsoft Visual Studio\VB10\Tasks\Personal\Tasks after using App.path
           Dim iCounter As Integer
            Dim File As String
            Dim myDate As String
            If Right$(strPath, 1) <> "\" Then strPath = strPath & "\"
            If Trim$(Extention) = "" Then
                Extention = "*.*"
            ElseIf Left$(Extention, 2) <> "*." Then
                Extention = "*." & Extention
            End If
            File = Dir$(strPath & Extention)
            Do While Len(File)
                  myDate = (Format(txtTaskDate, "mm-dd-yyyy"))
              ' Debug.Print File
                cboTasks.AddItem File
                 ReDim Preserve gArrYearly(iCounter)
                  ' gArrYearly(iCounter) = gTasksFolder & File
        '         Debug.Print "test " & gArrYearly(iCounter) ' typical  C:\Users\Public\Documents\Personal\Tasks\Yr8-3-2016.rtf
                 iCounter = iCounter + 1
                File = Dir$
   Don' think win 10 will allow writing to C:\temp
End Sub
isnoend2001Author Commented:
Got it, never mind
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.