AnsweredAssumed Answered

Arcmap VBScript: Replace multiple values in one label

Question asked by Bolitochrome on May 30, 2017
Latest reply on May 31, 2017 by kenbuja

I have a polygon shapefile of land units with dozens of attributes. I use multiple attributes to label each land unit. One attribute has three possible values: "Y", "N", or " " (not NULL).

If possible, in a single label string, I would like to replace the "Y" and the "N" with different text. For example:

"Y" = "HIGH"

"N" = "LOW"

 

I have been able to replace one or the other successfully using a variety of different VBScripts such as this one:

Function FindLabel ([TYPECD] )
  FindLabel = Replace([TYPECD],"Y","HIGH") & Replace([TYPECD],"N","LOW")
End Function

However, the result is a label that has BOTH values in it. Example: " HIGH Y" or "N LOW"

Is there a way to nest REPLACE within itself so that it replaces both "Y" and "N"?

 

Alternately, is there a way have one string ignore all other content besides the value I am replacing? For example, if I do HIGHStr = Replace([TYPECD],"Y","HIGH")  and ignore everything else

LOWStr = Replace([TYPECD],"N","LOW") and ignore everything else

Then I could just use FindLabel = HIGHStr & LOWStr

 

I know I could achieve this by defining classes of features and labeling them differently. However, I am trying to implement this labeling across many layers in many different maps, so loading a single expression would go much faster.

Outcomes