LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Text box in userform

Justr teasing Tim<G.

This is where my comment about rules came in, as I assumed the input could
be 2,3,4,5, or 6 characters. If it is always 6, you could simply do

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)

If KeyCode = 13 Then

Dim MyDate As Variant
With Me.TextBox1
If Len(.Value) = 6 Then
MyDate = Mid(.Value, 1, 2) & "/" & Mid(.Value, 3, 2) & "/" &
Mid(.Value, 5, 2)
If IsDate(MyDate) Then
.Text = Format(CDate(MyDate), "mm/dd/yy")
Else
MsgBox "Input is not a date"
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End If
Else
MsgBox "Input must be 6 digits"
.SelStart = 1
.SelLength = Len(.Text)
.SetFocus
End If
End With
End If

End Sub

It goes loopy with 29th Feb 2003 as an example though.

--

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,
I meant that as a compliment, I have read some of your posts in the

past. I don't care if the textbox thinks that it a number. I just want to
get the format to be 12/34/56 or if it was text ab/cd/ef. You are correct
about what Chris has said when I read it I thought that it would owrk but
when I cahnged it to fit in to my ccode it failed. So I am still working on
it. I would think that I may have another problem in this code because I am
also going to want to do this for the time, but I will conquer that when I
get to that point. If I can get this date thing to work then the time thing
will be easy. Thanks for the help


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
UserForm text will not wrap pgarcia Excel Discussion (Misc queries) 1 September 11th 07 11:44 PM
Text box on userform pcrobinson Excel Programming 3 January 8th 04 08:32 AM
Userform and Text Box Jamie[_6_] Excel Programming 5 December 16th 03 04:44 PM
userform text boxes Jo[_4_] Excel Programming 4 September 23rd 03 03:38 AM
Userform text box John Wilson Excel Programming 0 September 10th 03 07:31 PM


All times are GMT +1. The time now is 05:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"