Here is the VBScript I use in Arcmap Label Expression to generate my labels:

Function FindLabel ( [label1] , [label2] , [label3] , [label4] , [label5] , [label6] , [label7] , [label8], [label9], [label10], [label11], [label12], [label13], [label14])
Dim s
Dim value
Dim join
Dim label

label = [label1] &[label2] & [label3] & [label4] & [label5]  & [label6] & [label7] & [label8] & [label9] & [label10] & [label11] & [label12] & [label13] & [label14]

s = SPLIT(label ,"|") 

label = " "
For Each value in s
    label= label  & vbNewLine & value

FindLabel = trim(label)

End Function

The results are great except I am left with an extra "new line" on top, from which I have to go back to manually delete (attached pic)

enter image description here

How could I edit the code so it does not create that extra "newline" on top?

  • are you sure that [label1] has a vale? I think if it's NULL, then you it would print a NULL string then make a new line for Label2.... – Zipper1365 Jan 8 '20 at 16:44
  • The field [Label1] should always have a value. If there is no chemical compound, at least the value would be the Name of the point. – Dang Phung Jan 8 '20 at 17:05

You are initializing the label with a white space, then for each s you add a new line and the s value. After the 1st s, the label is therefore white space + newline + s1

You could add the new line after the s value:

label = " "
For Each value in s
    label= label & value & vbNewLine 

Note that you way want to initialize with an empty char ("") instead of a space (" ")

  • Thank you! The vnNewLine after the Value fix my problem! – Dang Phung Jan 8 '20 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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