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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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
 
Upvote 0

Forum statistics

Threads
1,223,360
Messages
6,171,629
Members
452,412
Latest member
thomasleysen531

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