Maliki Hassani
asked on
Excel: Masking password in VBA
Experts:
I am looking to add a masking over the password that a person is typing in the input box. Currently, my code shows the code.. Any ideas on where to look?
I am looking to add a masking over the password that a person is typing in the input box. Currently, my code shows the code.. Any ideas on where to look?
Here's a good tip I contributed to recently. Several options, though I like mine the best :). It might do the trick.
https://www.experts-exchange.com/questions/26818311/Password-Mask-in-INPUT-BOX-for-VBA.html
dave
https://www.experts-exchange.com/questions/26818311/Password-Mask-in-INPUT-BOX-for-VBA.html
dave
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
LANCE_S_P,
Try the attached file - code below.
If in the Userform you select the TextBox and look at its Properties you will see that the Password character has been set to *. That means that whenever you press a key only an asterix will be shown in the TextBox. When you press the 'Use password' button it checks whether you have entered the correct password. If the password is correct the Userform will be hidden and unloaded.
In practice you of course need to lock the VBA project so that people cannot just read the VBA code to find out what the password is.
Patrick
Try the attached file - code below.
If in the Userform you select the TextBox and look at its Properties you will see that the Password character has been set to *. That means that whenever you press a key only an asterix will be shown in the TextBox. When you press the 'Use password' button it checks whether you have entered the correct password. If the password is correct the Userform will be hidden and unloaded.
In practice you of course need to lock the VBA project so that people cannot just read the VBA code to find out what the password is.
Patrick
Private Sub CommandButton1_Click()
If LCase(Me.TextBox1.Text) = "qwerty" Then
MsgBox "Password was correct"
Me.Hide
Unload Me
Else
MsgBox "Password was incorrect"
End If
End Sub
password-masking-01.xls
ASKER
This was what I was looking for. Hackers are out there, this works best in vba.. Thanks
LANCE_S_P,
>Hackers are out there, this works best in vba..
My solution only works in VBA!
Patrick
>Hackers are out there, this works best in vba..
My solution only works in VBA!
Patrick
To do this:
1) right click your input box, and click "Properties".
2) In the "Properties" window, you should see "PasswordChar". Just put a character there.