Don’t put rules for validating text values or formats in the KeyPress event-use the Change event instead. If you “paste” into a text box, the KeyPress event isn’t fired and all your validation goes out the window. Also, if you don’t carefully put code in the Change event that sets the value of a text box, you’ll create an infinite loop:
Private Sub Text1_Change() 'Append asterisk to text Text1.Text = Text1.Text & "*"End Sub
Here’s a better way:
Private Sub Text2_Change() Dim lCurr As Long 'Append asterisk to text lCurr = Text2.SelStart If Right$(Text2.Text, 1) <> "*" Then Text2.Text = Text2.Text & "*" 'Be kind and don't put the cursor at the front of the 'text Text2.SelStart = lCurr End IfEnd Sub