VB Script Labeling for Attributes in One Field - how to stack and truncate labels?

1321
10
08-18-2013 02:33 PM
TiaMorita
New Contributor III
I have a shapefile with a field I am using for labels. The attributes in this field are long company names. I will be publishing the contents of this map to ArcGIS Portal as a map service too, so I want to clean up my labels.

First, I'd like to stack the labels.
Second, I would like to truncate them by replacing common words in all these company names (eg. replace Company with "Co.", Beverage with "Bev.", Distributing with "Dist.", and so on...)

Is there a single script where I can accomplish both?

Thanks!
Tags (2)
0 Kudos
10 Replies
RichardFairhurst
MVP Honored Contributor
--------------
rfairhur24,

Thanks so much for your earlier help. This script has been working great! Just curious if there's a way to update it so it stacks my lllabels after the first word. For instance, if the company name is "Pacific Beverage Company", the script would still replace "Company" with "Co.", but stack the label where Beverage Company comes as a single line under Pacific.

Thanks for your help,
tiamo


Try this:

Function FindLabel([dist_name])
  Dim name
  If IsNull([dist_name]) Then
    name = ""
  Else
    ' Add as many replace expressions as you need.
    ' The first string in the pair must match your input exactly to be replaced.
    ' The order of replace statements matters.
    ' Words that can be part of other replaced words must come last.
    name = [dist_name]
    name = Replace(name, " ", vbNewLine, 1, 1)
    name = Replace(name, "Limited Liability Company", "LLC")
    name = Replace(name, "Company", "Co")
    name = Replace(name, "Beverage", "Bev")
    name = Replace(name, "Distributed", "Dist")
  End if
  FindLabel = name
End Function
0 Kudos