kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
Hi,
I have been searching for the solution to this for a while now but I can't seem to get the right solution.
How do I check for the availability of symbols such as, @,!,@, and so on?
That's any character that's not a number or letter.
I found this on the Web.
As the above code is check for caps, lower case and numbers, I need another criteria to check for special characters or symbols.
Thanks in advance
Kelly Mort.
I have been searching for the solution to this for a while now but I can't seem to get the right solution.
How do I check for the availability of symbols such as, @,!,@, and so on?
That's any character that's not a number or letter.
I found this on the Web.
Code:
Sub Password()
Dim b As Integer
Dim i As Integer, j As Integer, k As Integer
Dim psw As String
Dim hasNum As Boolean, hasUpper As Boolean, hasLower As Boolean
Dim LengthOFPasswordsList As Long
LengthOFPasswordsList = Range("D" & Rows.Count).End(xlUp).Row
For b = 3 To LengthOFPasswordsList
'assume the password is no good.
hasNum = False
hasUpper = False
hasLower = False
'capture the psw in question
psw = Range("D" & b)
'see if there is a number in the password
'NOTE: the following For loops uses the ASCII values for numbers and letters.
For k = 48 To 57
If (InStr(1, psw, Chr(k))) Then
hasNum = True
Exit For
End If
Next k
'See if there is an upper case
For i = 65 To 90
If (InStr(1, psw, Chr(i))) Then
hasUpper = True
Exit For
End If
Next i
'See if there is a lower case
For j = 97 To 122
If (InStr(1, psw, Chr(j))) Then
hasLower = True
Exit For
End If
Next j
'See if all criteria was met
If Not hasLower Or Not hasUpper Or Not hasNum Or (Len(psw) <> 8) Then
Range("F" & b) = "Password Inválida"
End If
Next b
End Sub
As the above code is check for caps, lower case and numbers, I need another criteria to check for special characters or symbols.
Thanks in advance
Kelly Mort.