Format year problem

T

Todd Huttenstine

Bernie your message showed up as unavailable. Can you
post again.

Private Sub TextBox1_Exit(ByVal Cancel As
MSForms.ReturnBoolean)
TextBox1.Value = Format(TextBox1.Value, "mm/dd/yyyy")
End Sub


The above code formats the textbox. There is a problem.
If I were to type in 03/12/04 and then exit the textbox,
the textbox shows 1405 for the year.

Why?

Todd Huttenstine
 
T

Tom Ogilvy

Todd,

Probably because Textboxes return text, not dates.

Try

TextBox1.Value = Format(CDate(TextBox1.Value), "mm/dd/yyyy")

HTH,
Bernie
MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Format year problem 1
Calling an eventprocedure 3
A Question for Ron de Bruin 3
Text Box exit 10
Direct manipulation of TextBox 4
Stay in TextBox 2
Chosing from a Calendar 1
HELP WITH CODE 3

Top