Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Password Validation  (Read 3657 times)

0 Members and 1 Guest are viewing this topic.

kyle_engineer

    Topic Starter


    Intermediate
  • 010010110101100
  • Thanked: 4
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 7
Password Validation
« on: April 09, 2013, 12:49:58 PM »
So I have an MS Access db application that I'm working on. The part that i need help with, is validating password strings for the new user function. Simply, the add user form passes all the info to the SQL db. I ran into the problem of password strings containing symbols not wanting to work at all, though it would pass to the db just fine, wouldn't allow logging in with them. Also, if the initial character was a number, it didn't like that either. As long as these two conditions weren't there, then it works perfectly. Creates the user and their credentials are ready for use in <30s. But if it starts with numbers or contains symbols - merp. no work.  :-\

So, the thing that I'm going for is one of two option; A) a functioning string validation technique that find prohibited characters in string, and checks to make sure the first char is alpha only; B) a way to get it to accept any password regardless of what characters it contains (no nulls and 6+ char).

I started trying us instr and like in if statements, but neither of them works right. They don't stop the process or even display their msgbox correctly. Even though they should, they don't. :(

Anyway, all help is appreciated. :)
"Any answer is only as good as it satisfies the question." - Me

0000000100101011000 -
010010010010000001001100010011110100110 001000000010110010100111101010101

kyle_engineer

    Topic Starter


    Intermediate
  • 010010110101100
  • Thanked: 4
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 7
Re: Password Validation
« Reply #1 on: April 09, 2013, 08:10:36 PM »
Alright, I partially figured this out... just a little more tuning needed.

Code: [Select]
Option Compare Database
'textbox check function
Public Function IsAlphaNum(ByVal sString As String) As Boolean
     If Nos sString Like "*[!0-9A-z]*" Then IsAlphaNum = True
     ' This is the part that needs tuning.
     If Not sString Like "#*" Then IsAlphaNum = True
     'Basically this is attempting to prohibit the first char from being a number.
End Function
'----------------------
Private Sub Test_Click()
If IsAlphaNum(Me.BoxTest) = False Then
     MsgBox "Password must be alphanum and can't start with a num."
     Exit Sub
Else
     MsgBox "password accepted."
End If
End Sub


The code, as shown above, doesn't stop numbers from being the first char. It blocks symbols just fine, but not initial numbers... I've tried a few different methods to get it to accept both if statements, but it hasn't wanted to work. I've tried Or, And, AndAlso (which i think it correct), and even a nested-if... none of them seem to want to work, so i must be doing something wrong...  ???

Thanks in advance.
 - kyle_engineer
"Any answer is only as good as it satisfies the question." - Me

0000000100101011000 -
010010010010000001001100010011110100110 001000000010110010100111101010101

kyle_engineer

    Topic Starter


    Intermediate
  • 010010110101100
  • Thanked: 4
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 7
Re: Password Validation
« Reply #2 on: April 09, 2013, 08:35:33 PM »
Wow... so sorry I solved my own problem... but here's what worked for me! I hope people in the community use this. :)

Code: [Select]
Option Compare Database
'---------------------------------------------------------
'textbox check function
Public Function IsAlphaNum(ByVal sString As String) As Boolean
Dim strFirstChar As String
     If Not sString Like "*[!0-9A-z]*" Then IsAlphaNum = True
     strFirstChar = Left(Me.BoxPassword, 1)
     If IsNumeric(strFirstChar) Then IsAlphaNum = False     
End Function
'----------------------
Private Sub Test_Click()
If IsAlphaNum(Me.BoxPassword) = False Then
     MsgBox "Password must be alphanum and can't start with a num."
     Exit Sub
Else
     MsgBox "password accepted."
End If
End Sub
"Any answer is only as good as it satisfies the question." - Me

0000000100101011000 -
010010010010000001001100010011110100110 001000000010110010100111101010101