Programmers are in the habit of creating meaningful identifiersby concatenating the words of a “title case” phrasethat describes the identifier, such as LastName or FinalPaymentDate.Often, you can use these names to create labels or column headingsat run time. SpaceName takes such an identifier and inserts spacesappropriately. Thus, X$ = SpaceName “FinalPaymentDate”)returns “Final Payment Date”:
Function SpaceName (src As String) _ As String Dim i As Integer, tgt As string tgt = Left$(src, 1) For i = 2 To Len(src) Select Case Mid$(src, i - 1, 1) Case "a" To "z" Select Case Mid$(src, i, 1) Case "A" To "Z":tgt = _ tgt & " " End Select End Select tgt = tgt & Mid$(src, i, 1) Next i SpaceName = tgtEnd Function