|
-
December 19th, 2010, 02:13 PM
#1
Help with function, password checker
Aim - trying to create a password strength checker that updates the progress bar as user types in password. keep getting errors. not to familiar with byref and function
Public Function PasswordQuality(LengthScore As Integer, _
UCaseScore As Integer, LCaseScore As Integer, _
NumberScore As Integer, SpecCharScore As Integer, _
TotalScore As Integer) As Integer
Const Space As String = " "
Dim Uppercase As Boolean
Dim UCaseScore As Integer
Dim LengthScore As Integer
Dim Lowercase As Boolean
Dim LCaseScore As Integer
Dim Numbers As Boolean
Dim NumberScore As Integer
Dim SpecialChar As Boolean
Dim SpecCharScore As Integer
Dim TotalScore As Integer
Dim PasswordLength As Long
Const Space As String = " "
PasswordLength = Len(Text1.Text)
If InStr(Text1.Text, Space) > 0 Then
MsgBox "Please make sure that the password you have entered does not contain any spaces", vbInformation + vbOKOnly, "Incorrect password"
Exit Function
End If
If Len(Text1.Text) < 6 Then
MsgBox "Please make sure that the password is greater than 6 characters", vbInformation + vbOKOnly, "Incorrect password"
Exit Function
End If
If Len(Text1.Text) > 6 Then
LengthSscore = 20
If Asc(Text1.Text) > 64 And Asc(Text1.Text) < 91 Then Uppercase = True
UCaseScore = 20
If Ascii(Text1.Text) > 96 And Asc(Text1.Text) < 123 Then Lowercase = True
LCaseScore = 10
If Ascii(Text1.Text) > 47 And Asc(Text1.Text) < 58 Then Numbers = True
NumberScore = 20
If Ascii(Text1.Text) > 32 And Asc(Text1.Text) < 48 Then SpecialChar = True
SpecCharScore = 20
End If
TotalScore = LengthScore + UCScore + LCaseScore + NumberScore + SpecCharScore
PasswordQuality = TotalScore
End Function
Private Sub Text1_Change()
ProgressBar1.Value = PasswordQuality
End Sub
any help would be appreciated
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|