format file names to be used as dates

I am trying to remove the file extensions and any letters from file names so i can use them as dates
in one call
example: call to function
function RemoveFileName(Name as  string) as string
remove here
end function
calling function
dim myDate as date
mydate = RemoveFileName("9-20-2015.rtf") or
mydate = RemoveFileName("Mo10-25-2016.rtf")


9-20-2015.rtf
9-21-2015.rtf
9-25-2015.rtf
Yr9-20-2015.rtf
Yr10-25-2016.rtf
Dy1000.rtf'time
Wk10-25-2016.rtf
Mo10-25-2016.rtf
Yr10-25-2016.rtf
Wk10-25-2016.rtf
10-22-2016.rtf
10-21-2016.rtf
11-25-2016.rtf
Yr9-20-2016.rtf
Yr10-25-2016.rtf
Dy10-25-2016.rtf
Wk3-25-2016.rtf
Mo10-25-2016.rtf
Yr5-25-2016.rtf
Wk9-25-2016.rtf
Dy0630.rtf'time
Dy0900.rtf'time
Wk10-25-2016.rtf
Yr10-25-2016.rtf
Wk10-25-2016.rtf

Open in new window

not sure if this a proper name format for a date
10-25-2016
how can this be written ?
isnoend2001Asked:
Who is Participating?

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

x
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.

Rgonzo1971Commented:
HI,

You don't say what you want for the time

Function removeFilename(strDate As String) As Date
Select Case UCase(Left(strDate, 2))
    Case "WK", "YR", "MO"
        Res = Left(Right(strDate, Len(strDate) - 2), Len(strDate) - 6)
    Case "DY"
        Res = Left(Right(strDate, Len(strDate) - 2), Len(strDate) - 6)
        If Res Like "####" Then
            MsgBox "it's a Time"
            Exit Function
        End If
    Case Else
        Res = Left(strDate, Len(strDate) - 4)
End Select
removeFilename = Res
End Function

Open in new window

Regards

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:
The Time sb
Dy0630.rtf would be 0630 with the Dy and .rtf removed
Rgonzo1971Commented:
then try

Function removeFilename(strDate As String) As Date
Select Case UCase(Left(strDate, 2))
    Case "WK", "YR", "MO", "DY"
        Res = Left(Right(strDate, Len(strDate) - 2), Len(strDate) - 6)
    Case Else
        Res = Left(strDate, Len(strDate) - 4)
End Select
removeFilename = Res
End Function

Open in new window

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.