' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Function IsUpperLetter(c)
    v = Asc(c)
    If 65 <= v And v <= 90 Then
        IsUpperLetter = True
    Else
        IsUpperLetter = False
    End If
End Function

Function IsLowerLetter(c)
    v = Asc(c)
    If 97 <= v And v <= 122 Then
        IsLowerLetter = True
    Else
        IsLowerLetter = False
    End If
End Function

' Note that non-ASCII letters like the 3 special Danish letters are treated like special characters
Function IsValidPassword(pw, minLen, minUC, minLC, minDig, minSpec)
    nUC = 0
    nLC = 0
    nDig = 0
    nSpec = 0
    For i = 1 To Len(pw)
        c = Mid(pw, i, 1)
        If IsUpperLetter(c) Then
            nUC = nUC + 1
        ElseIf IsLowerLetter(c) Then
            LC = nLC + 1
        ElseIf IsNumeric(c) Then
            nDig = nDig + 1
        Else
            nSpec = nSpec + 1
        End If
    Next
    If Len(pw) >= minLen And nUC >= minUC And nLC >= minLC And nDig >= minDig And nSpec >= minSpec Then
        IsValidPassword = True
    Else
        IsValidPassword = False
    End If
End Function

WScript.ECho CStr(IsValidPassword("ABC", 3, 0, 1, 0, 0))

