![]() |
![]() |
|
|||||||
| 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: Sydney, Australia
Posts: 2,908
|
Here's some code which should do what you need. It assumes that the textbox is called TextBox1 and the button is called CommandButton1. You might want to change the PasswordChar property of the password so you only see ******* when typing the password.
HTH, D Code:
Private Sub CommandButton1_Click()
Dim intRetry As Integer
If Me.TextBox1.Text <> "HELLO" Then
intRetry = MsgBox("Do you want to try again?", vbYesNo, "Incorrect Password")
If intRetry = vbNo Then
ThisWorkbook.Close False
Else
Me.TextBox1.Text = ""
Me.TextBox1.SetFocus
End If
End If
End Sub
[ This Message was edited by: dk on 2002-03-02 13:03 ] |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|