I'm trying to make a user form for data entry and I have a textbox with tariff codes. the layout is ####.##.##.## which the macro works well at formatting. problem is when you try to backspace you cannot go past any of the periods. I tried to trap a backspace event as a condition for not putting the period but it does not seem to work. also I tried to prevent the user from entering their own periods and that isn't working either.
any help would be much appreciated.
Thanks,
Chris
Private Sub FITextBox14_Change()
Dim KeyAscii As Integer
If KeyAscii = 46 Then
KeyAscii = 0
End If
If Len(FITextBox14.Text) = 4 And KeyAscii <> vbKeyBack Then
FITextBox14.Text = FITextBox14.Text & Chr(46)
End If
If Len(FITextBox14.Text) = 7 And KeyAscii <> vbKeyBack Then
FITextBox14.Text = FITextBox14.Text & Chr(46)
End If
If Len(FITextBox14.Text) = 10 And KeyAscii <> vbKeyBack Then
FITextBox14.Text = FITextBox14.Text & Chr(46)
End If
End Sub
Bookmarks