416-621-9348 cgreaves@chrisgreaves.com Visit www.ChrisGreaves.com for this image! Chris_GEDC1894_Head (Small).JPG
Home Site About Services Products

Proper Case (Home), Camel Case , The Essential Function

Proper Case and Camel Case

End-users of Microsoft Word are familiar with the use of the Format, Change Case menu item that permits us to change the text in a document to Proper case. The Microsoft method has some flaws, and so the developer writes a macro to overcome limitations of Microsoft’s implementation. These notes discuss what can be done to assist the end-user.

Additionaly the developer wants a function to Proper-case any given string - not just the text selected in a Word document. For example, the developer might want to proper-case street addresses in an Access database field.

The early version of the function strProperCase serves both the end-user and the developer.

Function strProperCase(ByVal strIn As String, strReference As String) As String

For extra background information, search the web for proper title case word .

Our considerations for the developer function include the following points:

The incoming string can be any length, even an empty string

We define a word as being a string of consecutive characters from the set of alphabetics and the single quote character, bounded or terminated by a character not from that set. (Thus “there’s” is a word because the characters come from the set “abcdefghijklmnopqrstuvwxyz’ABCDEFGHIJKLMNOPQRSTUVWXYZ”.

None-word text is transmitted unchanged.

We always capitalize the first word of the string, which means we are tretaing the incoming string a sbeing a sentence.

We transmit unchanged any word that consists solely of upper-case letters.

We transmit unchanged any word that is found in our reserved Word list (see below)

We capitalize any other word

The input string "it is that there's III and then we've got BBB, you see!" will thus be translated to “It is that There'S III and then we'Ve Got BBB, you see”.

Our default reserved word list is current;ly defined as “,a,all,an,and,for,from,in,is,it,of,on,see,so,that,the,then,to,up,we,we've,with,you,”

Our considerations for the end-user macro include the following points:

We do not process text that spreads acros table cell boundaries

We would like to process a selected paragraph automatically

Camel Case


Loading

Toronto and Mississauga, Friday, March 19, 2010 12:01 PM

Copyright © 1996-2010 Chris Greaves. All Rights Reserved.