Prompting for a pass word?
Eliminate Pivot Table Annoyances
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: Prompting for a pass word?

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Posts
    117
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    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. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    2,936
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    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 ]

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 

 
DMCA.com