Thread: Uppercase Check
View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
Rick Rothstein \(MVP - VB\)[_1449_] Rick Rothstein \(MVP - VB\)[_1449_] is offline
external usenet poster
 
Posts: 1
Default Uppercase Check

I don't think the function I posted originally catches everything correctly;
however, I am pretty sure this one does...

Function IsMinimalPassword(PW As String) As Boolean
Const AllowableCharacters As String = "A-Za-z0-9@_."
IsMinimalPassword = (PW Like "*#*#*" Or PW Like "*[A-Z]*[A-Z]*" Or _
PW Like "*[!A-Za-z0-9]*[!A-Za-z0-9]*") And _
Len(PW) 5 And InStr(PW, " ") = 0 And _
Not PW Like "*[!" & AllowableCharacters & "]*"
End Function

Observe that I changed the constant to show all allowable characters as
opposed to just non-alphanumeric characters. I preloaded the constant string
with the non-alphanumeric characters underline, dot and the 'at' symbol...
just remove any of these that shouldn't be allowed and add any characters to
the end of the constant string that should be allowed, subject to the same
notes I posted in my first message, namely...

Note 1: If you are going to allow a dash (-) to be one of the
non-alphanumeric characters, it must be placed as the last characters in the
string of characters assigned to the NonAlphaNumerics constant.

Note 2: You cannot have the closing square bracket ( ] ) as an allowable
non-alphanumeric character (if this is a problem, the function can be
modified to handle it).

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
If I understood your extended goal correctly, and if I didn't make a
mistake<g, the following function should guarantee that there are either
two digits or two upper case letters or two non-alphanumeric characters in
the password string and that the non-alphanumeric characters come from a
specified pool of allowable characters (none of which can be the space
character) and that the password string is at least 6 characters long.

Function IsMinimalPassword(PW As String) As Boolean
Const NonAlphaNumerics As String = "@_."
IsMinimalPassword = (PW Like "*#*#*" Or PW Like "*[A-Z]*[A-Z]*" _
Or (PW Like "*[!A-Za-z0-9]*[!A-Za-z0-9]*") _
And PW Like "*[" & NonAlphaNumerics & "]*[" & _
NonAlphaNumerics & "]*") And InStr(PW, " ") = 0 _
And Len(PW) 5
End Function

Note 1: If you are going to allow a dash (-) to be one of the
non-alphanumeric characters, it must be placed as the last characters in
the string of characters assigned to the NonAlphaNumerics constant.

Note 2: You cannot have the closing square bracket ( ] ) as an allowable
non-alphanumeric character (if this is a problem, the function can be
modified to handle it).

Rick


"Duncan" wrote in message
...
Hi Guys,

Been a long while since I posted on here!

Does anyone know how to look at a textbox, and see if at least one of
the letters is uppercase?

Basically I need to try to recreate microsofts password complexity doo-
dah to check my textbox against, essentially at least 6 charecters,
and two of them have to be either uppercase, number or charecter. (not
both of the same),... anyway thats hard to explain properly and doesnt
really matter at this early stage but I am sure you get what I am
trying to do.

The first bit I want to tackle is to see if there is an uppercase
letter. Any ideas?

Many thanks in advance

Duncan