UserForm password masking not working

KarinG

New Member
Joined
Nov 17, 2017
Messages
6
Hi.
I created a UserForm that accepts a password. The property PasswordChar is set to *. This works great in Excel 2010. When I try using the form in Excel 2016 it does not work. The password is literally all asterisks. Any idea on what is happening and how I fix this? I really would like the password to be what I type in and not all stars. :)
Thanks for your help.
Karin
 
Ok remove the passwordChar property & try this
Code:
[COLOR=#0000ff]Option Explicit
Public disev As Boolean
Dim StrPasswd As String
Dim StrAsterisks As String[/COLOR]


Private Sub CommandButton1_Click()
    MsgBox StrPasswd
End Sub
Sub Textbox1_Change()

If disev = True Then GoTo xit

    StrPasswd = StrPasswd & Right(TextBox1.Text, 1)
    Debug.Print StrPasswd
    StrAsterisks = StrAsterisks & "*"
disev = True

    TextBox1.Value = StrAsterisks
xit:
disev = False

End Sub
The items in blue must go at the very top of the module
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
This is with your code as well
Code:
Option Explicit
Public disev As Boolean
Dim StrPasswd As String
Dim StrAsterisks As String


Private Sub cmdSubmit_Click()
    Dim Ws As Worksheet
disev = True
    Me.Hide
    On Error GoTo PasswordError
        MsgBox StrPasswd
        For Each Ws In ActiveWorkbook.Worksheets
            Ws.Unprotect Password:=StrPasswd
        Next Ws
        StrPasswd = ""
        StrAsterisks = ""
        Me.txtPassword.Value = ""
        MsgBox "All worksheets unlocked"
        Unload Me
    Exit Sub
PasswordError:
    MsgBox "Invalid password - please try again."
    StrPasswd = ""
    StrAsterisks = ""
    Me.txtPassword.Value = ""
    Me.Show
'    txtPassword.SetFocus
End Sub

Sub txtpassword_Change()

If disev = True Then GoTo xit

    StrPasswd = StrPasswd & Right(txtPassword.Text, 1)
    Debug.Print StrPasswd
    StrAsterisks = StrAsterisks & "*"
disev = True

    txtPassword.Value = StrAsterisks
xit:
disev = False

End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,215,005
Messages
6,122,661
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top