Uppercase Check

D

Duncan

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
 
G

gordon.moar

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

I've had to do this before and found a usenet post by Chip Pearson (as
always!) that pointed in the right direction. Basically, you can loop
through the string and test each character for upper/lowercase by
comparing the original string character to the same character
converted to upper case. Keep a count of the characters that are
upper case and Bob's yer uncle.

Think this is the link that got me moving on this
http://groups.google.co.uk/group/mi...read/thread/b35eb8b206b10ac3/c2742809be4c10a0
 
G

gordon.moar

I've had to do this before and found a usenet post by Chip Pearson (as
always!) that pointed in the right direction.  Basically, you can loop
through the string and test each character for upper/lowercase by
comparing the original string character to the same character
converted to upper case.  Keep a count of the characters that are
upper case and Bob's yer uncle.

Think this is the link that got me moving on thishttp://groups.google.co.uk/group/microsoft.public.excel.programming/b...

Forgot to mention, you can use isnumeric to test for numbers in the
same Select Case statement.
 
D

Dan R.

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

Try something like this:

mystr = "ssSss"
For i = 1 To Len(mystr)
If Mid(mystr, i, 1) = UCase(Mid(mystr, i, 1)) Then
Debug.Print i
End If
Next
 
D

Duncan

Try something like this:

mystr = "ssSss"
For i = 1 To Len(mystr)
  If Mid(mystr, i, 1) = UCase(Mid(mystr, i, 1)) Then
    Debug.Print i
  End If
Next

Hi Dan,

Worked perfectly, thanks. I used it in the following:

mystr = Password1.Text
For i = 1 To Len(mystr)
If Mid(mystr, i, 1) = UCase(Mid(mystr, i, 1)) Then
Checky = Checky + 1
GoTo Nxt1
End If
Next
Nxt1:
For i = 1 To Len(mystr)
If Mid(mystr, i, 1) = IsNumeric(Mid(mystr, i, 1)) Then
Checky = Checky + 1
GoTo Nxt2
End If
Next
Nxt2:
For i = 1 To Len(mystr)
If Mid(mystr, i, 1) = LCase(Mid(mystr, i, 1)) Then
Checky = Checky + 1
GoTo Nxt3
End If
Next
Nxt3:

Then I will check to see if Checky = 3

Many thanks again

Duncan
 
D

Dave Peterson

Try a password of 1 or 123 or $$$1....

ucase(non-letter) = lcase(non-letter) = non-letter
 
D

Dave Peterson

Another one:

Dim myStr As String
Dim OkPwd As Boolean
myStr = "1234Ea"

If Len(myStr) > 5 _
And InStr(1, myStr, " ", vbTextCompare) = 0 _
And myStr Like "*[A-Z]*" _
And myStr Like "*[a-z]*" _
And myStr Like "*[0-9]*" Then
OkPwd = True
Else
OkPwd = False
End If

MsgBox OkPwd
 
R

Rick Rothstein \(MVP - VB\)

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
 
R

Rick Rothstein \(MVP - VB\)

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) said:
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 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top