Function to evaluate whether a string is all UPPER

B

Brad Smith

I'm trying to clean up strings in a web form before I plug the fields
into a database. Lots of folks like to leave caps lock key on and
yell their form entries.

I can figure out how to change strings to sentence case, but I don't
want to do it to every string since some correctly entered words e.g.
"to" would be converted unnecessarily (to "To"). I'm willing to live
with the over correction on a few strings, but don't want to apply it
to the entire database.

Has anyone used a function to evaluate whether a string has been
entered all in upper case?


Thanks,

Brad Smith
pbs at myrealboxNOSPAM.com
remove NOSPAM from address and replace at with @ to email me directly
 
K

Kevin Spencer

Convert the string to all upper case, and compare the result to the original
string. If they are equal, the original string is all upper case.

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Big things are made up of
lots of Little things.
 
B

Blaise Pascal Tine

Hi Brad,

Could you try this:

string a = "Dodo";
if (a == a.ToUpper())
{
// the string is all in uppercase!
}

Thanks,
Blaise Pascal Tine (MSFT).
--------------------
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top