Have function written by another coder that needs mofifaction using vb6

need to send "Dy900.rtf" to the function and return 9:00AM
the code:

Function NewFileName(parmFileName)
    Dim strFileName As String
    Dim strPeriod As String
    
    strFileName = parmFileName
    strPeriod = Left(strFileName, 2)
    strFileName = Left(strFileName, InStrRev(strFileName, ".") - 1)
    Select Case LCase(strPeriod)
        Case "wk"
            strPeriod = "ww"
        Case "mo"
            strPeriod = "m"
        Case "yr"
            strPeriod = "yyyy"
        Case Else
    End Select
    
    NewFileName = Left(parmFileName, 2) & Format(DateAdd(strPeriod, 1, CDate(Mid(strFileName, 3))), "mm-dd-yyyy") & Mid(parmFileName, InStrRev(parmFileName, "."))

End Function

Open in new window

Function NewFileName(parmFileName)
    Dim strFileName As String
    Dim strPeriod As String
    
    strFileName = parmFileName
    strPeriod = Left(strFileName, 2)
    strFileName = Left(strFileName, InStrRev(strFileName, ".") - 1)
    Select Case LCase(strPeriod)
        Case "wk"
            strPeriod = "ww"
        Case "mo"
            strPeriod = "m"
        Case "yr"
            strPeriod = "yyyy"
        Case Else
    End Select
    
    NewFileName = Left(parmFileName, 2) & Format(DateAdd(strPeriod, 1, CDate(Mid(strFileName, 3))), "mm-dd-yyyy") & Mid(parmFileName, InStrRev(parmFileName, "."))

End Function

Open in new window

how can this be done ?
isnoend2001Asked:
Who is Participating?
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:
It looks like you want to extract the time from the file name, but the function you show (twice) adds 1 to the date and produces a new file name.
1
isnoend2001Author Commented:
Did not realize it did that only want the time extracted in am/pm
can you fix it ?
0
Martin LissOlder than dirtCommented:
Yes. Please remind me what the"Wk" and "yr" files look like.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Martin LissOlder than dirtCommented:
Haven't I done this for you previously?
0
isnoend2001Author Commented:
Mo10-25-2016.rtf
 Wk9-25-2016.rtf
 Yr9-20-2016.rtf
0
isnoend2001Author Commented:
Haven't I done this for you previously?
No
0
isnoend2001Author Commented:
gotta run an errand be back in a few hours
0
Martin LissOlder than dirtCommented:
Try this.

Private Function GetDate(strFileName As String) As String
Dim intPos As Integer
Dim strTime As String

intPos = InStrRev(strFileName, ".")
Select Case LCase(Left$(strFileName, 2))
    Case "dy"
        strTime = Mid$(strFileName, 3, intPos - 3)
        GetDate = Format(Left$(strTime, Len(strTime) - 2) & ":" & Right$(strTime, 2), "HH:MM AM/PM")
    Case Else
        GetDate = Format(Mid$(strFileName, 3, intPos - 3), "mm-dd-yyyy")
End Select
End Function

Open in new window

The question I was thinking about was this one.
0

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:
Thank you just what i needed
0
Martin LissOlder than dirtCommented:
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you
including these two new ones.
Creating your own Excel Formulas and doing the impossible
A Guide to Writing Understandable and Maintainable VBA Code
Marty - MVP 2009 to 2015, Experts-Exchange Top Expert Visual Basic Classic 2012 to 2014
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.