Results 1 to 5 of 5

Thread: Anyone...Need code to check each letter of password..

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    4
    I am trying to enter a password. When you enter the first letter of the password wrong a label tells you Incorrect Password. It also works if you enter the first letter right and the second letter wrong. But if I enter the first two letters right and the third letter wrong it doesn't work. This is the code I used:

    PrgmPassword = Text1
    If Text1 = "Paula" Then
    SetStringValue "HKEY_LOCAL_MACHINE", "String Value", PrgmPassword
    Unload Me
    Form2.Show
    End If
    If Text1 <> "Paula" Then
    Label30 = clr
    Label1.Caption = "Incorrect Password - Try Again"
    End If
    If Text1 = "" Then
    Label1.Caption = clr
    Label30 = "Please Insert Password"
    End If
    If Text1 < "Paula" Then
    Label30 = "Please Insert Password"
    Label1.Caption = clr
    End If

    Can anyone help me on this?



  2. #2
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Whats the point in that cos if it tells u after each letter if its right or wrong then people will find it easy to crack the password.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  3. #3
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    He's right, this is a very insecure method of checking a password - are you just doing this as an exercise or are you planning on using it?

    What does this line mean? :

    If Text1 < "Paula" Then

    I would use something like this:

    Code:
    If Left("Paula", Len(Text1.Text)) <> Text1.Text Then
    'string entered is not the start of the string "Paula"
    Harry.

    "From one thing, know ten thousand things."

  4. #4
    Lively Member
    Join Date
    Aug 2000
    Posts
    117
    You can execute a test every time a letter is pressed by using the KeyPress Event
    Code:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
    If Left("Paula", Len(Text1.Text)) <> Text1.Text Then
    End Sub

  5. #5
    Lively Member
    Join Date
    Nov 1999
    Location
    Cincinnati, OH
    Posts
    66

    Cool

    if you want to do this, the best way is string paring
    Text1_Change
    Dim PW as string
    Dim x as ling, y as long

    PW = Password' whatever that may be
    if Right$(PW, 1) = Right$(Text1.Text) Then
    'Code for correct Paswword here
    else
    'Code for incorrect password here
    end if
    end sub



Posting Permissions

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



Click Here to Expand Forum to Full Width