HOW TO

Display labels using proper case

Last Published: April 25, 2020

Summary

This article includes the procedure for displaying labels using the proper case. For example, a field with a city name such as 'PORT HOPE' will be labeled as 'Port Hope'.

Procedure



  1. Click the Label Manager button on the Labeling toolbar.
  2. Check the box next to the layer to be labeled.
  3. Choose a label class under the layer.
  4. Click the Expression button.
  5. Check on the Advanced check box.
  6. Replace the existing code with the following:

    Code:
    Function FindLabel ( [LABELFIELD] )
    FindLabel = PCase( [LABELFIELD] )
    End Function

    Private Function PCase(byVal string)
    Dim Tmp, Word, Tmp1, Tmp2, firstCt, a, sentence, c, i
    If IsNull(string) Then
    PCase = Null
    Exit Function
    Else
    string = CStr( string )
    End If
    a = Split( string, vbCrLf )
    c = UBound(a)
    i = 0
    For each sentence in a
    Tmp = Trim( sentence )
    Tmp = split( sentence, " " )
    For Each Word In Tmp
    Word = Trim( Word )
    Tmp1 = UCase( Left( Word, 1 ) )
    Tmp2 = LCase( Mid( Word, 2 ) )
    PCase = PCase & Tmp1 & tmp2 & " "
    Next
    PCase = Left( PCase, Len(PCase) - 1 )
    If i = c then
    Else
    PCase = PCase & vbCrLf
    End If
    i = i + 1
    Next
    End Function


    Note:
    When using this code, replace all occurrences of the LABELFIELD field name with the name of the field in your table.
  7. Click OK.
  8. On the Label Manager dialog box, click Apply and click OK.

Article ID:000008157

Software:
  • ArcMap

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic