How to Skip or Preserve Certain Characters in Labels

6786
0
02-26-2010 04:00 AM
by Anonymous User
Not applicable
0 0 6,786

Hello, this is Cassandra with tips on removing or saving characters in label expressions. I recently helped a customer who wanted to label his points without the first two characters in each value. For example, his data looked like this:Attributes of Wells dialog box

But he wanted the labels to look like this:

To skip the first two characters in each label string, we used the VBScript operator 'Mid':

Mid ([field], <#_to_skip>, <#_of_total_string_length>).

So for this example where I'm labeling WELL_IDS, the label expression would look like this:

Mid ([WELLS_ID], 3, 100).

We need to set the number of characters to skip to three instead of two, due to how the Mid operator works. Also, because the total number of characters after the 'CL' changes, we can set the total string length to a value larger than any of the strings in the field.

Likewise, you can also use the Left or Right operators to set which characters display. For example, you might want to display the first two characters on one line and the remaining characters on a second line. Using my example values above, the label expression would look like this:

Left ([WELLS_ID], 2) &vbcrlf& Mid ([WELLS_ID], 3, 100).

Or if the string values have a fixed total character length of seven, for example, you could use:

Left ([WELLS_ID], 2) &vbcrlf& Right ([WELLS_ID], 5).

See the ArcGIS Desktop Web Help topic About building label expressions for more information.
Cassandra L. - Desktop Support Analyst