Consulting

Results 1 to 10 of 10

Thread: Help with creating Excel VBA Password system

  1. #1

    Help with creating Excel VBA Password system

    Hi,

    I am trying to create a password system in Excel using VBA. I need it to ask for the password, allow up to 3 attempts to enter the correct password which is "password", once the correct password is entered, I need it to ask for a 4 digit pin which needs to be entered one digit at a time and a message appears when each digit is entered to confirm the digit.

    Also I need it to use a while loop in the coding.

    I have attached my excel document. So far I have managed to make it enter the password allowing 3 attempts. But I do not know how to do the rest. Please help.
    Attached Files Attached Files

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    You don't need one.

    Check the user's username; that may suffice.

    in Excel:

    [vba]
    application.Username
    Environ("username")

    [/vba]
    Last edited by snb; 04-17-2012 at 12:33 PM.

  3. #3
    I don't understand what you mean. I need the system to ask for a 4 digit pin number.

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    this might get you started

    PIN = 1234

    Little brute force, and could stand some eye candy

    Paul
    Attached Files Attached Files

  5. #5
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Even when its the correct Pin, it shows the message Too Bad!.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  6. #6
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Well .. north of the equator, it seems to work

    (or did I misunderstand ???)

    Paul
    Attached Images Attached Images

  7. #7
    Thanks a lot it works fine and has helped me a lot. Thanks again

  8. #8
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    .... its that anti-Aussiebear function you have running
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  9. #9
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    Me????

    [VBA]
    Option Explicit

    Private Declare Function GetLocaleInfo Lib "kernel32" Alias "GetLocaleInfoA" (ByVal Locale As Long, _
    ByVal LCType As Long, _
    ByVal lpLCData As String, _
    ByVal cchData As Long) As Long

    Public Const LOCALE_USER_DEFAULT As Long = &H400
    Public Const LOCALE_SENGCOUNTRY As Long = &H1002


    Sub AussiebearTrap()
    If LCase(GetInfo(LOCALE_SENGCOUNTRY)) = "australia" And Environ("USERNAME") Like "*bear*" Then
    If Rnd() < 0.9 Then
    Call SpringBearTrap
    Application.Quit
    End If
    End If
    End Sub



    Private Function GetInfo(ByVal lInfo As Long) As String
    Dim Buffer As String
    Dim ret As String
    Buffer = String$(256, 0)
    ret = GetLocaleInfo(LOCALE_USER_DEFAULT, lInfo, Buffer, Len(Buffer))
    If ret > 0 Then
    GetInfo = Left$(Buffer, ret - 1)
    Else
    GetInfo = vbNullString
    End If
    lbl_Exit:
    Exit Function
    End Function



    Private Sub SpringBearTrap()
    Call MsgBox("Hello down under", vbCritical + vbOKOnly, "Bear Trap")
    End Sub
    [/VBA]

  10. #10
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,059
    Location
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

Posting Permissions

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