Consulting

Results 1 to 4 of 4

Thread: User Form Help

  1. #1
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location

    User Form Help

    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.

  2. #2
    VBAX Expert Leith Ross's Avatar
    Joined
    Oct 2012
    Location
    San Francisco, California
    Posts
    552
    Location
    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"

  3. #3
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    thanks
    Peace of mind is found in some of the strangest places.

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •