Hello
Anyone who has designed a textbox with Date Format ie with DD-MMM-YYYY through Class Event. Though in Class Event Textbox dont have Exit, Enter, BeforeUpdate and After update so become difficult for the result when numeric values entered in the text box and result to be displayed in date format through beforeupdate or exit event
though the above is possibe for a textbox designed on the userform and then form initialized and not at run time
the code for the textbox exit event below which enters numeric values to form the date on Userform below as follows. in similar way would like textbox with Date format when form loaded at run time with Class Module Event
Code
Option Explicit
Public mDate As Date
Dim DisableEvents As Boolean
Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If DisableEvents Then Exit Sub
If Mid(TextBox3.Value, 4, 2) > 12 Or Not IsDate(Me.TextBox3.Value) Then
Cancel = True
MsgBox "Date Not Valid, Kindly Re-enter", vbCritical
TextBox3.Value = vbNullString
TextBox3.SetFocus
Exit Sub
End If
mDate = DateSerial(Year(Date), month(Date), day(Date))
TextBox3.Value = Format(CDate(TextBox3.Value), "dd-mmm-yyyy")
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
DisableEvents = True
End Sub
Display More
SamDsouza