Text box in userform
Tim,
I don't know if you mean that as a compliment or a criticism<vbg.
You could check the KeyDown event for the enter key
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If KeyCode = 13 Then
Dim MyDate As Variant
MyDate = Me.TextBox1
If IsDate(MyDate) Then
Me.TextBox1.Text = Format(MyDate, "mm/dd/yy")
End If
End If
End Sub
But I am confused, if you enter the date as you suggest as 41304, Chris'
suggested method will not work as it will fail the IsDate test, because it
isn't a date, it's a number.
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Tim" wrote in message
...
Bob,
You always look little deeper then the rest of us. I understand what
Chris was saying and that will work fine for my needs at this poont. But
what I still don't underestand is how do you update the textbox after the
user leaves the textbox. The only way that I can see how to do this is when
the user clicks a command button. I want to do it before that.
Thanks
----- Bob Phillips wrote: -----
Tim,
this needs some rules. Is 11204 11th Feb 2004, or 1st Dec 2004? Once
you
have the rules, it will be a simple matter of formatting with MID
function
etc.
--
HTH
Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
"Tim" wrote in message
...
I have a text box in a user form that has the user put in a date. I
want
the text box to change the format mm/dd/yyyy in the text box if the
user
puts the date in like this 41304 when they tab or click to the next
textbox
it would format the date to this 04/13/04. I am not sure how to do
this.
Help would be greatly appreciated.
Thanks
|