-
Jan 5th, 2012, 06:59 AM
#1
Thread Starter
New Member
Test a string for upper and lower case?
How do you test a string entered by the user via a userform for uppercase? If any uppercase letters are present in the string I want it to return true, it it does not contain lowercase I want it to return false...
Thanks!
Last edited by jasminalison; Jan 5th, 2012 at 07:07 AM.
-
Jan 5th, 2012, 08:35 AM
#2
Addicted Member
Re: Test a string for upper and lower case?
Originally Posted by jasminalison
How do you test a string entered by the user via a userform for uppercase? If any uppercase letters are present in the string I want it to return true, it it does not contain lowercase I want it to return false...
Thanks!
I'm assuming you meant to say "if it does not contain uppercase I want it to return false"
This should return true if there are any uppercase letters
Function containsUpperCase(testString As String) As Boolean
containsUpperCase = (testString <> LCase(testString))
End Function
-
Jan 5th, 2012, 03:36 PM
#3
Re: Test a string for upper and lower case?
if you want to confirm a mix of upper and lower case
vb Code:
Function casemixed(s As String) As Boolean If Not (LCase(s) = s Or UCase(s) = s) Then casemixed = True End Function
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|