|
-
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
-
December 19th, 2010, 02:26 PM
#2
Re: Help with function, password checker
have corrected the ascii( errors already and lengthSscore = 20 still errors though.
-
December 19th, 2010, 05:38 PM
#3
Re: Help with function, password checker
Correct the code by using TAGS, and also post what error occurs on what line
Also, look at this code (by itself)
Code:
Option Explicit
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Sub Form_Activate()
ProgressBar1.Min = 0
ProgressBar1.Max = 100
ProgressBar1.Value = 0
ProgressBar1.Enabled = True
Dim x As Integer
Dim q As Long
For x = 0 To 100
DoEvents
ProgressBar1.Value = x
Sleep 50
Next x
MsgBox "Done"
Unload Me
End Sub
Run it and see the bar update
Last edited by dglienna; December 19th, 2010 at 05:41 PM.
-
December 21st, 2010, 11:11 AM
#4
Re: Help with function, password checker
You can't use ASC nor ASCII in the way that you are attempting in the OP. If you want to check the string to see if a given character is Upper or Lower case you must use another method.
ASC() returns the numeric character value of a single character not of a string of characters.
You need to loop through the string and check each character one by one to get the result you seem to be looking for.
Always use [code][/code] tags when posting code.
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
|