Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

StrConv problems

Status
Not open for further replies.

mrmetal

Technical User
Jul 8, 2005
16
US
I have a string that is assembled from various fields. I would like to be able to convert this string to an actual sentence - first letter of first word capitalized, with no other capitalizations.

I first tried an input mask, but because the values will be of varying length, that did not work. Next, I tried using the StrConv method, but every word gets capitalized.

Is there a way to capitalize only the first letter of the first word?

Thanks for the help

Ed
 
Geoff, can I alter a little?
[tt]
UCase (Left(MyString, 1)) & LCase(Mid(MyString, 2))[/tt]

________________________________________________________________________
Zameer Abdulla
Visit Me
A person who misses a chance and the monkey who misses its branch can't be saved.
 

You can even use instr() to look for ". " (period space) and then capitalise the next character after that as well. And check if it ends in a period and add one if it doesnt.
 
Thank's guys - it worked very well. I'm trying to understand the code, however, and am confused what the numbers mean. Does it mean that:
1. the code reads the string from left to right
2. beginning at the first letter, everything gets capitalized
3. beginning at the second letter (because of the number 2 in the second part of the code) everything is converted to lowercase.

Additionally, what is the difference between Geoff's code and Zameer's code. I tried them both to see if I could tell the difference, but they both worked.

Thanks

Ed
 
Yes that is correct with the following exception

2) The first letter only gets capitalized.

The only difference is that LCase insured that every letter after the first letter was in lower case, in case someone enter a capital letter elsewhere in the string.
 
lesw1433 said:
The only difference is that LCase insured that every letter after the first letter was in lower case, in case someone enter a capital letter elsewhere in the string.
True

________________________________________________________________________
Zameer Abdulla
Visit Me
A person who misses a chance and the monkey who misses its branch can't be saved.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top