Sub testpassword()
pass = "ABCD1234"
MsgBox (checkValidPassword(pass))
End Sub
Function checkValidPassword(ByVal pwd As String) As Boolean
If Len(pwd) <> 8 Then Exit Function
If Not isUpperCaseLetter(Mid(pwd, 1, 1)) Then Exit Function
checkValidPassword = True
For i = 2 To Len(pwd)
If Not myIsNumber(Mid(pwd, i, 1)) And Not isUpperCaseLetter(Mid(pwd, i, 1)) Then checkValidPassword = False
Next i
End Function
Function isUpperCaseLetter(ByVal c As String) As Boolean
If Len(c) <> 1 Then Exit Function
If UCase(c) <> LCase(c) Then 'verify the character is a letter
If UCase(c) = c Then isUpperCaseLetter = True 'verify that the letter is uppercase
End If
End Function
Function myIsNumber(ByVal c As String) As Boolean
Dim i As Integer
If Len(c) <> 1 Then Exit Function
On Error Resume Next
i = c * 1 'this creates an error if c is not a number
If Err.Number = 0 Then myIsNumber = True 'if no error then true
End Function