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

Rgonzo1971Commented:
Hi,

pls try

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

Open in new window

Regards
0
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.
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:
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")
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.

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.
0
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
0
isnoend2001Author Commented:
Thanks
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Smart! Glad your issue has been resolved.
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.