[GIS] Using VBScript to label shapefile in ArcMap

arcgis-desktoparcmaplabelingvbscript

If you're reading this for the first time, it might be best to focus on section beneath ANOTHER UPDATE.

I'm a beginner with VBScript and I have a question about using an VBScript expression for a label. I want to label street address numbers and the fractional address number, if it exists, in my map. This data is stored in an address points shapefile. I go Properties > Labels > Expression… in Esri software to enter this expression:

[HSE_NO]&" "& [FRAC_NO] 

With this expression the labels will be created next to the address points as follows:

 412 1/2 412

See how both labels are on the same line? I would like to have the labels look like this:

412
412 1/2

I want the first label to be the address value without a fraction, and the following lines would be address values with fractions. I welcome your suggestions.

UPDATE

I think what I need is more complex than I realized. As I mentioned, I want first label to be address street value (HSE_NO) without a fraction (where FRAC_NO is NULL). I'm working on getting this to occur with what's below. It's not correct! Any ideas?

Function FindLabel ( [HSE_NO], [FRAC_NO] )
if (IsNull[FRAC_NO]) then
    FindLabel = [HSE_NO] 
    End If
End Function

ANOTHER UPDATE

I have a point shapefile of addresses. Some address points contain the address number and street name. Some points contain address number, address fractional number, and street name. Points containing fractional values will overlap points containing not containing fractional values. I want to label these overlapping points like this:

1159
1159 1/2

My current VBScript labels addresses in this manner.

1159 1/2 1159

Does anyone know how to get the desired result? Here's my current expression:

Function FindLabel ( [HSE_NO], [FRAC_NO] )
  if (IsNull([FRAC_NO])) then
    FindLabel = [HSE_NO]
  else
    FindLabel = [HSE_NO] & " " & [FRAC_NO] 
  End If
End Function

Best Answer

You should use vbNewline for this

Your expression should be

[HSE_NO] & vbNewLine & [FRAC_NO]

If you want to check if FRAC_NO is null, then you can use the following code

Function FindLabel ( [HSE_NO], [FRAC_NO] )
  IF (IsNull([FRAC_NO])) Then
    FindLabel = [HSE_NO]
  else
    FindLabel = [HSE_NO] & vbNewLine & [FRAC_NO] 
  End If
End Function

See these pages for more examples:

  1. Label expression by way of VBScript

  2. HowTo: Use advanced label expressions in ArcMap