G
Guest
I've a procedure (given below) that attempts to indicate Password strength to
User who wants to change his/her log on Password. But, I'm not convinced
about the elegance of this procedure.
Can someone help me with a better code ?
Private Sub Password_AfterUpdate()
On Error GoTo Err_PasswordAfterUpdate
Dim i As Integer
Dim counter As Integer
Dim AscTest As Integer
Dim AscResult As Integer
Dim SplChar As Integer
Dim ModResult As Integer
'Get the length of the Password
counter = Len(Trim(Me!Password))
For i = 1 To counter
AscTest = Asc(Mid(Me!Password, i, 1))
'Find if user enters Alphabets
If (AscTest >= 65) And (AscTest <= 122) Then
AscResult = AscResult + 1
End If
'Find if user enters Numbers
If (AscTest >= 48) And (AscTest <= 57) Then
AscResult = AscResult + 2
End If
Next i
For i = 1 To counter
AscTest = Asc(Mid(Me!Password, i, 1))
'Find if user enters Special Characters
If (((AscTest >= 33) And (AscTest <= 47)) Or _
((AscTest >= 58 And (AscTest <= 64)))) Then
SplChar = SplChar + 1
End If
Next i
ModResult = AscResult Mod counter
If SplChar = 0 Then
If ModResult = 0 Then
'User is using only Alphabets or only Numbers
'Code to indicate that Password Strength is "WEAK"
Else
'User entered a combination of Alphabets and Numbers only
'Code that returns Password Strength as "MEDIUM"
End If
Else
'User also included a Special Character
'Code that returns Password Strength as "STRONG"
End If
Exit_PasswordAfterUpdate:
Exit Sub
Err_PasswordAfterUpdate:
ErrorLog "PasswordAfterUpdate", err, Error
Resume Exit_PasswordAfterUpdate
End Sub
User who wants to change his/her log on Password. But, I'm not convinced
about the elegance of this procedure.
Can someone help me with a better code ?
Private Sub Password_AfterUpdate()
On Error GoTo Err_PasswordAfterUpdate
Dim i As Integer
Dim counter As Integer
Dim AscTest As Integer
Dim AscResult As Integer
Dim SplChar As Integer
Dim ModResult As Integer
'Get the length of the Password
counter = Len(Trim(Me!Password))
For i = 1 To counter
AscTest = Asc(Mid(Me!Password, i, 1))
'Find if user enters Alphabets
If (AscTest >= 65) And (AscTest <= 122) Then
AscResult = AscResult + 1
End If
'Find if user enters Numbers
If (AscTest >= 48) And (AscTest <= 57) Then
AscResult = AscResult + 2
End If
Next i
For i = 1 To counter
AscTest = Asc(Mid(Me!Password, i, 1))
'Find if user enters Special Characters
If (((AscTest >= 33) And (AscTest <= 47)) Or _
((AscTest >= 58 And (AscTest <= 64)))) Then
SplChar = SplChar + 1
End If
Next i
ModResult = AscResult Mod counter
If SplChar = 0 Then
If ModResult = 0 Then
'User is using only Alphabets or only Numbers
'Code to indicate that Password Strength is "WEAK"
Else
'User entered a combination of Alphabets and Numbers only
'Code that returns Password Strength as "MEDIUM"
End If
Else
'User also included a Special Character
'Code that returns Password Strength as "STRONG"
End If
Exit_PasswordAfterUpdate:
Exit Sub
Err_PasswordAfterUpdate:
ErrorLog "PasswordAfterUpdate", err, Error
Resume Exit_PasswordAfterUpdate
End Sub