Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You're welcome - I'm glad it works for you.
I thought about this again and realised if you have a user that doesn't know they can omit the /'s they will get double slashes. So I added a line of code in each routine to avoid this: If InStr(.Text, "//") Then .Text = Replace(.Text, "//", "/") End If It works in both - see updated procedures below. HTH, Gareth Private Sub TextBox1_Change() With TextBox1 Select Case Len(.Text) Case 2, 5 .Text = .Text & "/" End Select If InStr(.Text, "//") Then .Text = Replace(.Text, "//", "/") End If End With End Sub Private Sub TextBox2_Change() Dim iPos As Integer Const myMask As String = "--/--/----" With TextBox2 If Len(.Text) = 1 Then .Text = .Text & myMask Exit Sub End If If InStr(.Text, "//") Then .Text = Replace(.Text, "//", "/") End If iPos = InStr(.Text, "-") If iPos = 0 Then Exit Sub .Text = Left$(.Text, iPos - 1) _ & Mid(myMask, iPos) iPos = InStr(.Text, "-") If iPos = 0 Then Exit Sub .SelStart = InStr(.Text, "-") - 1 End With End Sub johncassell wrote: Thanks very much for that Gareth, it worked exactly as I'd hoped and many thanks for replying in the first place. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
condtion for entering date | Setting up and Configuration of Excel | |||
In Excel 2003, entering date without slashes, the date is incorre. | Excel Discussion (Misc queries) | |||
converting date from a textbox to a date format | Excel Programming | |||
Excel 5.0 entering date | Excel Programming | |||
Selecting or Entering a Textbox | Excel Programming |