Can you hide password from being displayed as it is typed (Input box)?

I have a input box which prompts for a password (in excel) but I do not want the password displayed as it is typed.  I have searched on this is the site and see other questions which are similar but not quite the same.  Is this possible?
ilrosebud26Asked:
Who is Participating?
 
mvidasConnect With a Mentor Commented:
You can set the mask during setup of the userform. When you're seeing the form during design time, single-click the text box, and press F4 to open/focus on the Properties window. Scroll down to the PasswordChar property, and type  *  in there, and save the project.

I should note, however, that the sheet select statement here won't be run, since it occurs after you unload the form:

            Unload Me
            Sheets("Sheet2").Select

Matt
0
 
mvidasCommented:
Hi,

It is possible, just not with the built-in inputbox. You'd have to create a userform with a textbox on it, and set the .PasswordChar property to "*" or whatever character you want to show up in place of the actual input.

I made one a while back, I can upload it for you, might save you a couple minutes.
http://www.mvidas.com/mvfiles/vInputBox.zip

Unzip it, and import the .bas and .frm files into your project (or just copy the code from the .bas into an existing module). Then just call vInputBox instead of just InputBox, and set the vMaskInput variable to True, ie:

 Dim YourPassword As String
 YourPassword = vInputBox("Please enter password", vMaskInput:=True)

If you don't want the inputbox to be always on top (necessary for my usage), remove the UserForm_Activate subroutine.

Matt
0
 
Rory ArchibaldCommented:
It is possible but it would be much easier to build a simple userform with a text box and OK button, because then you can just set the PasswordChar property of the text box. If you want to do it with an InputBox, you need code like this: http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_20949769.html

Regards,
Rory
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
ilrosebud26Author Commented:
Matt-
    Thanks for the help.  I think I will go with the lesser of two evils.  For someone like me (who just statred doing vb) it seems easierjust  to build a user form with a textbox.  Others may disagree.

Rosemary
0
 
mvidasCommented:
Hi Rosemary,

I'll admit, I tried what Rory posted and do find it quite interesting, though I agree that the userform is the easier way to go. I just made my own inputbox userform (the linked file above) look like the built-in one with the same arguments to pass to it but adding the vMaskInput argument :)

Matt
0
 
ilrosebud26Author Commented:
Matt-
     I guess you can really tell than I am new at this.  Here is my vb (very simple, I know).  Where do I put the mask?

Private Sub OKButton1_Click()
    If TextBox1 = "password" Then
            ActiveWorkbook.Unprotect TextBox1
            Unload Me
            Sheets("Sheet2").Select
        Else
            MsgBox "Invalid password, please try again."
            TextBox1 = " "
    End If
End Sub

Rosemary
0
 
ilrosebud26Author Commented:
You are the best....thanks for your help!!

Rosemary
0
 
mvidasCommented:
Glad to help! And remember you can always use the one I have above (or use the same idea with a public variable to store the inputted text) if you want to make it more generally usable; really only useful if you want to store the password in a variable or will use it more than once in a routine, so the userform doesnt actually do anything except take input.

Remember that we're here if you have any more questions
Matt
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.