devxlogo

Converting Identifiers into Labels and Column Headings

Converting Identifiers into Labels and Column Headings

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
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist