I have this code:
Class Form1
Function ValidatePassword(ByVal pwd As String, Optional ByVal minLength As Integer = 8, Optional ByVal numUpper As Integer = 1, Optional ByVal numLower As Integer = 1, Optional ByVal numNumbers As Integer = 1) As Boolean
Dim upper As New System.Text.RegularExpressions.Regex("[A-Z]")
Dim lower As New System.Text.RegularExpressions.Regex("[a-z]")
Dim number As New System.Text.RegularExpressions.Regex("[0-9]")
If Len(pwd) < minLength Then
MsgBox("Password must consist of 8 characters as minimum!")
Return False
End If
If upper.Matches(pwd).Count < numUpper Then
MsgBox("Password must consist of uppercase letter!")
Return False
End If
If lower.Matches(pwd).Count < numLower Then
MsgBox("Password must consist of lowercase letter!")
Return False
End If
If number.Matches(pwd).Count < numNumbers Then
MsgBox("Password must consist of at least 1 digit character!")
Return False
End If
MsgBox("Password OK!")
Return True
End Function
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Label3.Text = ValidatePassword(TextBox1.Text)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
it works well to give me message if one of the condition is fulfilled. I want to get something like: For example, the input: askjf
then message box showed:
- Password must consist of 8 characters as minimum!
- Password must consist of uppercase letter!
- Password must consist of at least 1 digit character!
Can anybody help please? Thanks!
Aucun commentaire:
Enregistrer un commentaire