Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Uppercase Check
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Uppercase Check
On 12 Mar, 13:46, Duncan wrote:
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/mic...742809be4c10a0 -- Gordon |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Uppercase Check
On 12 Mar, 13:53, wrote:
On 12 Mar, 13:46, Duncan wrote: 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 thishttp://groups.google.co.uk/group/microsoft.public.excel.programming/b... -- Gordon- Hide quoted text - - Show quoted text - Forgot to mention, you can use isnumeric to test for numbers in the same Select Case statement. -- Gordon |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Uppercase Check
On Mar 12, 8:46*am, Duncan wrote:
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 -- Dan |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Uppercase Check
On 12 Mar, 14:00, "Dan R." wrote:
On Mar 12, 8:46*am, Duncan wrote: 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 -- Dan- Hide quoted text - - Show quoted text - 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 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Uppercase Check
Try a password of 1 or 123 or $$$1....
ucase(non-letter) = lcase(non-letter) = non-letter Duncan wrote: On 12 Mar, 14:00, "Dan R." wrote: On Mar 12, 8:46 am, Duncan wrote: 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 -- Dan- Hide quoted text - - Show quoted text - 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 -- Dave Peterson |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Uppercase Check
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 Duncan wrote: 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 -- Dave Peterson |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Uppercase Check
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 |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Uppercase | Excel Discussion (Misc queries) | |||
uppercase | Excel Discussion (Misc queries) | |||
Uppercase help | Excel Discussion (Misc queries) | |||
Uppercase help | Excel Discussion (Misc queries) | |||
Uppercase | Excel Worksheet Functions |