Thursday, October 12, 2006

Using LCase and UCase in ASP

These are pretty simple functions; nevertheless, in my traffic logs I see visitors showing up after conducting searches on how to change case in ASP... so here you go!

UCase changes everything to upper case:
response.write(UCase("abcde"))
will return
ABCDE
LCase() changes everything to lower case
response.write(LCase("ABCDE"))
will return
abcde
Here's a way to capitalize ONLY the first letter:
UCase(Left(("abcde"),1))
renders
Abcde
If you are converting to sentence case, you might want to put it in all lower case first, and then capitalize the first letter. Keep in mind that this doesn't account for proper names and other words that are normally capitalized: they will remain in lower case (supposing that's how they started out).

If you're not familiar with the Left() function I use above, here's another handy-dandy RetroWebDev post on string manipulation using Left, Right and Mid.

1 comment:

peter said...

you have to use CONCAT() to combine the two strings the above case only returns the the first letter of the string that has been converted to upper case....