![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Feb 2002
Posts: 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? |
|
|
|
|
|
#2 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Winnipeg
Posts: 2,330
|
Quote:
Code:
password = InputBox("Enter Password (case sensitive)")
If password = "HELLO" Then
Todd_UserForm.Show
End If
__________________
Barrie Davidson "You're only given a little spark of madness. You mustn't lose it." - Robin Williams |
|
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
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. |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Posts: 117
|
Thankyou, it was perfect
|
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Feb 2002
Location: Chippenham, UK
Posts: 136
|
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 :o)
__________________
Regards, Gary Hewitt-Long |
|
|
|
|
|
#6 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
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 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|