?
Solved

Excel: Masking password in VBA

Posted on 2011-02-24
6
Medium Priority
?
578 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

770 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