Proper Case (Home), Camel Case , The Essential Function
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. Programmers, and increasingly the general public, are increasingly aware of camel case, in which a string of alphabetic characters is broken into pseudo-words by the application of upper-case lettering.
The function strCamelCase serves both the end-user and the developer.
Function strCamelCase(ByVal strIn As String, lngMinimumWord As Long) As String
For extra background information, search the web for camel case word .
Our considerations for the developer function include the following points:
The incoming string can be any length, even an empty string
If the incoming string contains words as defined for Proper Case , then we can invoke Proper Case to capitalize the words and reduce the string by the non-alphabetic characters.
We would like to provide substitutes for any inter-word gaps, such as the underscore character, or delete the gaps altogether.
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 considerations for the end-user macro include the following points:
We do not process text that spreads across table cell boundaries
We would like to process a selected paragraph automatically
We can Camel-Case a word quite easily (where as in Proper Case a word is defined as a string of alphabetic characters)
To Camel-Case a phrase (a series of words) we can use the logic of Proper Case to identify words, and then Camel-Case each word, instead of coercing it to proper case.
We can then deal with the inter-word gaps, by eliminating them, replacing them with underscore, and so on.
An obvious solution is to provide the Proper Case code with a switch that determines whether to coerce a word to Proper Case or to Camel Case.
Proper Case can be provided with a second switch that determines whether the inter-word gap should be
(a) passed through unchanged
(b) replaced with a given character string
(c) eliminated (which might be replacement with an empty character string)
Our pool of Reserved Words will not be applied to Camel-Casing. The reserved Word string acts as our switch. If its length is non-zero, then proper-casing is called for; if the length is zero (an empty string), then we implement camel-casing.
An optional parameter determines the inter-word gap behavior. If the parameter is missing, then text which constitutes an inter-word gap is passed through unchanged. Otherwise the parameter is used as a string to replace the text of the inter-word gap. If the parameter is an empty string the effect will be to delete the inter-word gap.
Loading
Toronto and Mississauga, Wednesday, August 03, 2011 3:20 PM
Copyright © 1996-2011 Chris Greaves. All Rights Reserved.