HOW TO
Instructions provided describe how to use a label expression to convert a string that is upper case, lower case or mixed case to proper case. For example, if a string that is in the following formats:
"hello world"
"HELLO WORLD"
"hELLO wORLD"
The following label expression will convert the string to: "Hello World".
For information on how to do the equivalent steps in the ArcMap field calculator, see the link in the Related Information section below.
Code:
Function FindLabel ([MyFieldName])
FindLabel = PCase([MyFieldName])
End Function
Function PCase(strInput)
Dim iPosition
Dim iSpace
Dim strOutput
iPosition = 1
Do While InStr(iPosition, strInput, " ", 1) <> 0
iSpace = InStr(iPosition, strInput, " ", 1)
strOutput = strOutput & UCase(Mid(strInput, iPosition, 1))
strOutput = strOutput & LCase(Mid(strInput, iPosition + 1, iSpace - iPosition))
iPosition = iSpace + 1
Loop
strOutput = strOutput & UCase(Mid(strInput, iPosition, 1))
strOutput = strOutput & LCase(Mid(strInput, iPosition + 1))
PCase = strOutput
End Function
Code:
Function FindLabel ([MyFieldName1], [MyFieldName2], [MyFieldName3])
FindLabel = PCase([MyFieldName1] & " " & [MyFieldName2] & " " & [MyFieldName3])
End Function
Function PCase(strInput)
Dim iPosition
Dim iSpace
Dim strOutput
iPosition = 1
Do While InStr(iPosition, strInput, " ", 1) <> 0
iSpace = InStr(iPosition, strInput, " ", 1)
strOutput = strOutput & UCase(Mid(strInput, iPosition, 1))
strOutput = strOutput & LCase(Mid(strInput, iPosition + 1, iSpace - iPosition))
iPosition = iSpace + 1
Loop
strOutput = strOutput & UCase(Mid(strInput, iPosition, 1))
strOutput = strOutput & LCase(Mid(strInput, iPosition + 1))
PCase = strOutput
End Function
Article ID:000008837
Get help from ArcGIS experts
Download the Esri Support App