I would use the _TextChanged Event.
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim t As String = TextBox1.Text
'// Remaining code here.
End Sub
codeorder
Postaholic
2,124 posts since Aug 2010
Reputation Points: 256
Solved Threads: 387
Skill Endorsements: 8
Its up to you to decide on how strong a password is.
This will tell you how many uppercase, lowercase, numbers, and non numbers are in the password. You'll have to decide on what percentage of each is a strong password.
No one can decide for you what a "strong" password is.
You could add all the numbers up and depending on the total, set the color of your Label.
Not a very good approach, but a start.
Here is a code sample with a slightly modified version of Unhnd_Exception's code.
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim t As String = TextBox1.Text
Dim iUpper, iLower, iNumbers, iOther As Integer
For i As Integer = 0 To t.Length - 1 '// Loop thru all Characters in TextBox1.Text
If Char.IsLetter(t(i)) Then
If Char.IsUpper(t(i)) Then : iUpper += 2 '// 2 Points for UpperCase.
Else : iLower += 1 '// 1 Point for LowerCase.
End If
ElseIf Char.IsNumber(t(i)) Then : iNumbers += 3 '// 3 Points for #'s.
Else : iOther += 5 '// 5 Points for Special Charaters.
End If
Next
Dim iSetTotal As Integer = iUpper + iLower + iNumbers + iOther '// sum Total.
If iSetTotal <= 5 Then Label1.BackColor = Color.Red '// if Less than 6.
If iSetTotal > 5 AndAlso iSetTotal <= 10 Then Label1.BackColor = Color.Orange '// if Greater than 5 and less that 11.
If iSetTotal > 10 Then Label1.BackColor = Color.Green '// if Greater than 10.
End Sub
codeorder
Postaholic
2,124 posts since Aug 2010
Reputation Points: 256
Solved Threads: 387
Skill Endorsements: 8
__avd
Posting Genius (adatapost)
8,736 posts since Oct 2008
Reputation Points: 2,141
Solved Threads: 1,262
Skill Endorsements: 50
Netcode
Veteran Poster
1,037 posts since Jun 2009
Reputation Points: 43
Solved Threads: 70
Skill Endorsements: 0
Question Answered as of 1 Year Ago by
Unhnd_Exception,
codeorder,
__avd
and 2 others