Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am labeling certain Oil & Gas areas by Operator in ArcMap 10, using this expression:

"" & [OPERATOR] & "" & vbNewline & "" & [UNIT_NAME] & ""

enter image description here

The only problem is that when the operator includes an ampersand (&), the label messes up because it's reading it as part of the expression, and ends up looking like it does in the screenshot below.

I know that in PHP (from my experience programming unrelated to GIS), there is a way to escape certain characters, but I haven't been able to find it in VBScript.


share|improve this question

You can replace them in your script with the syntax

Function FindLabel ([LABELFIELD])
  NewString = Replace([LABELFIELD],"&","&")  
  FindLabel = "<ITA>" & NewString & "</ITA>"
End Function
share|improve this answer
Ok so here's what I changed my expression to, but it's still not working: <br /> <br /> Function FindLabel ( [OPERATOR], [UNIT_NAME] ) NewString = Replace ([OPERATOR],"&","&amp;") FindLabel = "<FNT size='8'>" & [OPERATOR] & "</FNT>" & vbNewline & "<BOL>" & [UNIT_NAME] & "</BOL>" End Function' – denim_dan Jun 29 '12 at 15:39
Because you have assigned the "replace" to a variable called "NewString", you have to replace [OPERATOR] in the findlabel portion to the variable: NewString. – SaultDon Jun 29 '12 at 15:51
This script works for me Function FindLabel ( [MODIFIER1], [TYPE] ) NewString = Replace( [MODIFIER1] ,"&","&amp;") FindLabel = "<FNT size='8'>" & NewString & "</FNT>" & vbNewline & "<BOL>" & [TYPE] & "</BOL>" End Function As SaultDon as said – kenbuja Jun 29 '12 at 15:55
Awesome, thanks guys! – denim_dan Jun 29 '12 at 16:07
You're welcome. Please mark the question as answered. – kenbuja Jun 29 '12 at 16:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.