ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   text box (https://www.excelbanter.com/excel-programming/289410-text-box.html)

Glenn

text box
 
Hi,

I have a textbox on a user form which is a date.
Currently user can put what they like in this field. Is
there a way where they must enter a date in XX/XX/XXXX
format

John Wilson

text box
 
Glenn,

Really no need to "force" them to enter it in that format.
Check to see if it's a valid date and then format it for them.

Private Sub TextBox1_AfterUpdate()
If IsDate(TextBox1) Then
TextBox1 = Format(TextBox1, "mm/dd/yyyy")
Else
MsgBox "Please enter a valid date"
End If
End Sub

John

"Glenn" wrote in message
...
Hi,

I have a textbox on a user form which is a date.
Currently user can put what they like in this field. Is
there a way where they must enter a date in XX/XX/XXXX
format





All times are GMT +1. The time now is 08:50 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com