I need to mask all but the last 6 characters in a text box on a user form. I know how to do the whole thing. How do you do part?
I need to mask all but the last 6 characters in a text box on a user form. I know how to do the whole thing. How do you do part?
Peace of mind is found in some of the strangest places.
Hello austenr,Add this code to your UserForm. You may need to change the name of text box to match your text box's name. The text will appear as all asterisks until another control on the UserForm receives the focus.
Dim Unmasked As String ' This goes in the General Declarations section Private Sub TextBox1_AfterUpdate() If Len(Unmasked) - 6 > 6 Then TextBox1.Value = Left(TextBox1, Len(TextBox1) - 6) & Right(Unmasked, 6) Unmasked = "" End If End Sub Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If KeyAscii 8 And KeyAscii 127 Then Unmasked = Unmasked & KeyAscii End If KeyAscii = Asc("*") End Sub Private Sub UserForm_Click() End Sub
Last edited by SamT; 11-03-2017 at 03:35 PM.
Sincerely,
Leith Ross
"1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG"
thanks
Peace of mind is found in some of the strangest places.
Leith,
How ever you posted that last, it one-lined the entire post. I fixed the code formatting.
Is the code missing some ><=
I expect the student to do their homework and find all the errrors I leeve in.
Please take the time to read the Forum FAQ