Change Date format 12/26/2015 to 12-26-2015 vb6

This does not work
FutureYr = Format(FutureYr, "mm-dd-yyyy")
It does not change the format.
How to do this ?
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.


pls try

FutureYr = Format(DateValue(FutureYr), "mm-dd-yyyy")

Open in new window

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
It depends on what is FutureYr? How you have declared it in your original code? Is it just a variable or a control? Are you assigning the FutureYr back to a cell on the sheet? So many questions and not sure you will get your logical answer unless you provide these details.

Otherwise as such nothing is wrong with statement.

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:
Sorry about the late reply,had to run an unexpected errand
Dim FutureYr As Date
this did not fix it:
FutureYr = Format(DateValue(FutureYr), "mm-dd-yyyy")
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Use MsgBox FutureYr or Debug.Print FutureYr to see the value in immediate window. Do you see it in desired format?

How do you know that you don't get it in right format? What do you do next with FutureYr, do you place its value on the sheet or what?

If you are placing the value of FutureYr on the sheet, that might not work as sheet's default date separator will take over.
isnoend2001Author Commented:
Have already used debug, don't know why vb ignores the format.
Have overcame the issue by converting the date to a string using cstr
isnoend2001Author Commented:
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Smart! Glad your issue has been resolved.
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.