Prompting for a pass word?

Todd_M

Board Regular
Joined
Feb 24, 2002
Messages
117
Hi-
I have a number of user forms in a project.Theres a few of them that I only want the user to access using a pass word. Im assuming the pass word box is a userform asking for the correct pass word and entering it into a textbox. What code would I use to confirm the correct pass word "HELLO" thats put in the textbox by the user when he/she clicks a commandbutton?
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
On 2002-03-02 10:32, Todd_M wrote:
Hi-
I have a number of user forms in a project.Theres a few of them that I only want the user to access using a pass word. Im assuming the pass word box is a userform asking for the correct pass word and entering it into a textbox. What code would I use to confirm the correct pass word "HELLO" thats put in the textbox by the user when he/she clicks a commandbutton?
Todd, would something like this work for you?

Code:
password = InputBox("Enter Password (case sensitive)")
If password = "HELLO" Then
    Todd_UserForm.Show
End If

Regards,
 
Upvote 0
If you want it specifically from the UserForm, then it would just be (case-insensitive): -

Private Sub CommandButton1_Click()

If Upper(TextBox1.Text) = "HELLO" Then
' Your code
Else:
MsgBox "Incorrect password"
' Your code, either end the process or just use exit sub to keep the form in place
End If

End Sub

Change the above to reflect the names of your command button and textbox.
 
Upvote 0
Don't forget to password protect your VB project that contains the code in, otherwise it is possible for someone to look at your code and see what the password is :eek:)
 
Upvote 0
Good point. You could also set the PasswordChar property of the textbox to *, so it only shows asterisks when you type in the password (right-click on your textbox in design mode, select Properties and scroll down to PasswordChar and change it from blank to *).
This message was edited by Mudface on 2002-03-02 12:12
 
Upvote 0

Forum statistics

Threads
1,214,375
Messages
6,119,167
Members
448,870
Latest member
max_pedreira

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top