Solved

Excel: Masking password in VBA

Posted on 2011-02-24
6
569 Views
Last Modified: 2012-05-11
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?
0
Comment
Question by:Maliki Hassani
6 Comments
 
LVL 16

Expert Comment

by:Peter Kwan
ID: 34976650
Do you require a macro for your masking? If no, you may consider setting "PasswordChar" for the Textbox Properties.

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.
0
 
LVL 42

Expert Comment

by:dlmille
ID: 34977174
Here's a good tip I contributed to recently.  Several options, though I like mine the best :).  It might do the trick.

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_26818311.html

dave
0
 
LVL 42

Accepted Solution

by:
dlmille earned 500 total points
ID: 34977191
I put the tip in an xlsm worksheet for you.  Click the button to prompt for password.

Apparently Daniel Klann should be credited with the actual masking code.  Here's one citation http://www.ozgrid.com/forum/showthread.php?t=72794&page=1

Note in this post:
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_26818311.html

  I suggest having an addin that is separate from the application, that can be protected, for password validation.  You may/may not need that level of protection but advise if you do and I'll assist.

Also, its pretty easy to break password protection, with all the software out there to support that.


Dave
Password-r1.xlsm
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 45

Expert Comment

by:patrickab
ID: 34978371
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
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

Open in new window

password-masking-01.xls
0
 

Author Closing Comment

by:Maliki Hassani
ID: 34978521
This was what I was looking for. Hackers are out there, this works best in vba..  Thanks
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34978534
LANCE_S_P,

>Hackers are out there, this works best in vba..

My solution only works in VBA!

Patrick
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question