Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Aug 6, 1997

Converting Identifiers into Labels and Column Headings

Programmers are in the habit of creating meaningful identifiers by concatenating the words of a "title case" phrase that describes the identifier, such as LastName or FinalPaymentDate. Often, you can use these names to create labels or column headings at run time. SpaceName takes such an identifier and inserts spaces appropriately. 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 = tgt
End Function

Pat Dooley
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date