text box in a form

Eddie G.

Board Regular
Joined
Feb 27, 2002
Messages
98
Is there a way to format a text box in a form so that I can enter a date like this: 110502 and have appear in the text box like this: 11/05/02? I can't find any way to do it in the properties window of the text box. I don't want to have to type in the / symbol.
 

Some videos you may like

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney

Colo

MrExcel MVP,
Joined
Mar 20, 2002
Messages
1,456
Hi Eddie,

Pls put this code on your Userform.
Change the event Exit to suit your needs. :biggrin:

<PRE>
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
With TextBox1
If IsDate(.Text) Then Exit Sub
.Text = Format(DateSerial(Right(.Text, 2), _
Left(.Text, 2), Mid(.Text, 3, 2)), "MM/DD/YY")
End With
End Sub
</PRE>
 

Watch MrExcel Video

Forum statistics

Threads
1,127,354
Messages
5,624,200
Members
416,017
Latest member
moritz210

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top