could someone smart enough either add annotations, or edit this code, so that it tells the user WHICH error has been made.
I can't figure it out
thank you very much!
I am looking at the public function routine, that validates the password entry. I want to know how i can make a message pop up with the specific error the user has made on entry.
regards!
Public Function ValidatePwd(varPassword As Variant) As Boolean
Dim blnValid As Boolean
Dim blnValidCriteria As Boolean
Dim intChar As Integer
blnValid = Len("" & varPassword) >= 4 And Len("" & varPassword) <= 12
If blnValid Then
blnValidCriteria = False
For intChar = 1 To Len("" & varPassword)
If InStr(1, "ABCDEFGHIJKLMNOPQRSTUVW", Mid(varPassword, intChar, 1), vbBinaryCompare) > 0 Then
blnValidCriteria = True
Exit For
End If
Next
blnValid = blnValidCriteria
End If
If blnValid Then
blnValidCriteria = False
MsgBox "Please enter an upper case letter!"
For intChar = 1 To Len("" & varPassword)
If InStr(1, "abcdefghijklmnopqrstuvw", Mid(varPassword, intChar, 1), vbBinaryCompare) > 0 Then
blnValidCriteria = True
Exit For
End If
Next
blnValid = blnValidCriteria
End If
If blnValid Then
blnValidCriteria = False
MsgBox "Please enter a lower case letter"
For intChar = 1 To Len("" & varPassword)
If InStr(1, "0123456789", Mid(varPassword, intChar, 1), vbBinaryCompare) > 0 Then
blnValidCriteria = True
Exit For
End If
Next
blnValid = blnValidCriteria
End If
ValidatePwd = blnValid
End Function
Private Sub txtPassword_BeforeUpdate(Cancel As Integer)
Cancel = Not ValidatePwd(Me.txtPassword)
If Cancel Then
MsgBox Me.txtPassword.ValidationText, vbInformation
End If
End Sub
I can't figure it out
thank you very much!
I am looking at the public function routine, that validates the password entry. I want to know how i can make a message pop up with the specific error the user has made on entry.
regards!
Public Function ValidatePwd(varPassword As Variant) As Boolean
Dim blnValid As Boolean
Dim blnValidCriteria As Boolean
Dim intChar As Integer
blnValid = Len("" & varPassword) >= 4 And Len("" & varPassword) <= 12
If blnValid Then
blnValidCriteria = False
For intChar = 1 To Len("" & varPassword)
If InStr(1, "ABCDEFGHIJKLMNOPQRSTUVW", Mid(varPassword, intChar, 1), vbBinaryCompare) > 0 Then
blnValidCriteria = True
Exit For
End If
Next
blnValid = blnValidCriteria
End If
If blnValid Then
blnValidCriteria = False
MsgBox "Please enter an upper case letter!"
For intChar = 1 To Len("" & varPassword)
If InStr(1, "abcdefghijklmnopqrstuvw", Mid(varPassword, intChar, 1), vbBinaryCompare) > 0 Then
blnValidCriteria = True
Exit For
End If
Next
blnValid = blnValidCriteria
End If
If blnValid Then
blnValidCriteria = False
MsgBox "Please enter a lower case letter"
For intChar = 1 To Len("" & varPassword)
If InStr(1, "0123456789", Mid(varPassword, intChar, 1), vbBinaryCompare) > 0 Then
blnValidCriteria = True
Exit For
End If
Next
blnValid = blnValidCriteria
End If
ValidatePwd = blnValid
End Function
Private Sub txtPassword_BeforeUpdate(Cancel As Integer)
Cancel = Not ValidatePwd(Me.txtPassword)
If Cancel Then
MsgBox Me.txtPassword.ValidationText, vbInformation
End If
End Sub