textbox show correct time in userform
I'm having problems with a textbox that I created in my userform. The
problem is I have the textbox set to display time ("hh:mm") in the 24
hour mode. Each time the user enters the correct time the textbox will
take the time, but when it re-opens it displays the time as numbers not
time. Once I click in and out of the textbox it reverts to the correct
time. I want the textbox to display the entered time when the userform
is opened.
How can I force my textbox to display time? My VBA code is as follows:
Private Sub TimeTextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
TimeTextBox1.Value = Format(TimeTextBox1.Value, "hh:mm")
End Sub
Put your code inside the following sub too:
Private Sub UserForm_Activate()
TimeTextBox1.Value = Format(TimeTextBox1.Value, "hh:mm")
End Sub
|