View Full Version : User Form Help
austenr
11-02-2017, 09:33 AM
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?
Leith Ross
11-03-2017, 12:00 PM
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
austenr
11-03-2017, 12:11 PM
thanks
Leith,
How ever you posted that last, it one-lined the entire post. I fixed the code formatting.
Is the code missing some ><=
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.