MrExcel Publishing
Your One Stop for Excel Tips & Solutions

PasswordChar help


Posted by Peter on August 21, 2001 8:35 AM

Hi,

I am trying to hide a password (what the user types in) for an inputbox.
Here is the code I am using, won't work for some reason as part of a macro - can anyone help? Or a code segment that does work would help too.

Thanks

Pete


If InputBox("Enter Password", "Password", PasswordChar = "*") = "test" Then
.
.
Else
MsgBox ("Password Incorrect")
End If


Posted by Matt Walker on August 21, 2001 8:42 AM

Hi,

Hope this is useful. I have a a userform that bars the user form seeing a worksheet. Using the textbox properties (in VBA) i changed the password character to * rather than use code.
Password and Welcome are userforms that i have in my macro. Simply change the "password" to suit your needs and the code following each "then".

If TextBox1 = "password" Then
Beep
MsgBox "Please note that this sheet has direct links to Stockcheck. Edit at your own risk!", vbExclamation, "Worth noting..."
If TextBox1 = "password" Then Password.Hide
If TextBox1 = "password" Then Welcome.Hide
If TextBox1 = "password" Then Application.WindowState = xlMaximized
Else
Beep
MsgBox "Wrong password! Try again", vbCritical, "Access denied"
End If