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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change case type of each 1st character of a word to Uppercase

Status
Not open for further replies.

dstrange

Programmer
Nov 15, 2006
87
CA
I want to be able to convert a string so that every first character of a word gets converted to uppercase and the remaining characters are lower case.

Below are examples of existing data on the left and how I would like them to be formatted when displayed.
ie.
this is a test = This Is A Test
THIS IS a TEst = This Is A Test
THISISATEST = Thisisatest
 
How about the StrConv function?

Code:
YourFormattedText = StrConv(YourText, vbProperCase)
Hope this helps

HarleyQuinn
---------------------------------
Get the most out of Tek-Tips, read FAQ222-2244 before posting.
 
Try;

Private Sub Command1_Click()

MsgBox StrConv("hello there", vbProperCase)

End Sub
 
That's what the link that dstrange provided suggests, Hugh...
 
Bob,

Thank you for responding.

No that was the solution that HarleyQuinn provided.

If you checked the timing of my message and the others you will see that I was (probably) writing it as HarleyQuinn and dstrange posted.

Happy New Year, Hugh
 
N.B ....

for something like "hello there"
StrConv("hello there", vbProperCase) is fine


BUT if it is Peoples names .....

Well watch things like O'Brian , MacFee





 
...and also watch things like U.S.A and U.K.

I use the keypress event in the text box to check if the leading character is chr(32) or chr(46). This doesn't get round the MacFee problem but can accomodate O'Brian.

[gray]Experience is something you don't get until just after you need it.[/gray]
 
So you were, Hugh. Sorry for the crabby sounding post.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top