Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

Screenshot: http://i.stack.imgur.com/gdKxB.png

share|improve this question
add comment

1 Answer

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
1  
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
2  
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
2  
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
1  
You're welcome. Please mark the question as answered. –  kenbuja Jun 29 '12 at 16:24
add comment

Your Answer

 
discard

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.