Stacking labels from within a single attribute field

449
4
02-17-2012 04:28 AM
JamesSiddle
New Contributor
Hi

Its been touched on in some of the archived posts, but I can't seem to get this to work.

I want to label some points using the contents of a single text field. I'm familiar with using vbnewline for doing this with seperate fields, its quite simple. But i'd like to be able to stack labels based on inserting a symbol of some description (e.g.  '/' or '*') into the single field

E.g. :

"Started 2010 / under construction / still waiting on management approval" to look like this:

Started 2010
under construction
still waiting management approval

I found the following vbscript example in an archived thread:

Function FindLabel ( [myField] )
FindLabel = Replace( [myField], "/", vbCrLf)
End Function


But the expression editor says that using the Replace command is incorrect.

Help?

Thanks
Tags (2)
0 Kudos
4 Replies
AlexeyTereshenkov
Regular Contributor III
Hi,

I've just tested using the script code you've posted and it works fine. I use ArcGIS 10 SP3. What's about you?

The workflow I use is: Layer Properties > check the Label features in this layer check box. Click the Expression button > check the Advanced check box > copy the code into the Expression text box. This is it. I guess you have not checked the Advanced option, so the parser cannot be used. Also make sure that the VBScript is used for Parser: option.

Function FindLabel ( [FieldName] )
FindLabel = Replace( [FieldName] , "/", vbCrLf)
End Function
0 Kudos
JamesSiddle
New Contributor
thanks for your reply

i've tried running it again, but made sure all of my fields in the column had something in them, and it worked fine. I think it was coming up with the error because there were some null values.

Thanks
0 Kudos
AlexeyTereshenkov
Regular Contributor III
Awesome, James, glad it played out well.
0 Kudos
MarkBoucher
Occasional Contributor III
I recently ran across a label script that wraps text: http://arcscripts.esri.com/details.asp?dbid=12607

It looks like it counts characters and finds spaces so that the wrap starts in a logical place. You can adjust the length of the wrap. If your data have a typical length and are in one field, this might work. If your data have variable lengths, what you have would likely work better.
0 Kudos