?
Solved

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

Posted on 2007-08-02
8
Medium Priority
?
217 Views
Last Modified: 2010-04-30
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?
0
Comment
Question by:ilrosebud26
  • 4
  • 3
8 Comments
 
LVL 35

Expert Comment

by:mvidas
ID: 19618013
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
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 19618021
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
 

Author Comment

by:ilrosebud26
ID: 19621213
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 35

Expert Comment

by:mvidas
ID: 19624952
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
 

Author Comment

by:ilrosebud26
ID: 19625920
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
 
LVL 35

Accepted Solution

by:
mvidas earned 500 total points
ID: 19626140
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
 

Author Comment

by:ilrosebud26
ID: 19626276
You are the best....thanks for your help!!

Rosemary
0
 
LVL 35

Expert Comment

by:mvidas
ID: 19626322
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
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…

840 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