increase the value of a string vb6

how can increase the year value in a string eg:
Dim myDate as string
myDate = "12-26-2015.rtf"
12-26-2015.rtf to 12-26-2016.rtf?
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:
DateAdd("y", 1, Split(test, ".")(0))

but that won't work directly if the string is, say, "Yr12-26-2015.rtf. You'll need to do it on the output of the function I wrote in your other question.
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:
I was trying to edit the question when you posted, then i got access denied
myDate = "12-26-2015.rtf"
12-26-2015.rtf to 12-26-2016.rtf?
Should be
myDate = "Yr12-26-2015.rtf"
Yr12-26-2015.rtf to Yr12-26-2016.rtf?
0
Martin LissOlder than dirtCommented:
In other words something like this.

Const MyString = "Yr12-26-2015.rtf"
Dim str As String

str = DateFromName(MyString)

MsgBox DateAdd("y", 1, Split(str, ".")(0))

Open in new window

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:
Let me know if you've see my post 40914396.
0
GrahamSkanRetiredCommented:
I can't identify function DateFromName, so I will post my effort
Sub NewFileName()
Dim strFilenameParts() As String
Dim strDateParts() As String
Dim dtDate As Date
Dim dtNewDate As String
Dim strNewName As String

strFilenameParts = Split("12-26-2015.rtf", ".")

strDateParts = Split(strFilenameParts(0), "-")
dtDate = DateSerial(strDateParts(2), strDateParts(0), strDateParts(1))
dtNewDate = DateAdd("yyyy", 1, dtDate)
strFilenameParts(0) = Format(dtNewDate, "mm-dd-yyyy")
strNewName = Join(strFilenameParts, ".")
End Sub

Open in new window

0
isnoend2001Author Commented:
Thanks yes i see it.
My plan is this:
Private Sub cmdDelete_Click()
Dim NewFileName as string
Dim fName As String
if LeftfName,2) = "Yr" then
    increase the yr by 1 and name it one yr more
    save the increased NewFileName
End If
kill FileName
0
Martin LissOlder than dirtCommented:
There's a potential problem with your plan. If the file chosen doesn't start with "Yr" you'll kill it without creating a new file, so

Private Sub cmdDelete_Click()
Dim NewFileName as string
Dim fName As String
if LeftfName,2) = "Yr" then
    increase the yr by 1 and name it one yr more
    save the increased NewFileName
Else
    Msgbox "Wrong File"
    Exit Sub
End If
kill FileName
0
isnoend2001Author Commented:
Marty Thats what i want it to do only create a new file + 1 yr if The file starts with Yr
0
isnoend2001Author Commented:
Clarification:
I made and have been using this program for a couple yrs
I wanted a way to create the file every year for birthdays etc
I decided to make it better by adding a checkbox: ckEveryYear
When creating the task if the checkbox is checked then "Yr" is added to the file name
this is a way to idenitify it to  make  a new file when deleted
0
Martin LissOlder than dirtCommented:
OK, let me know when and if you need more help.
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.