Stacking Labels in Vb

Q.  I use Vb to stack long label names in GIS and now need to add more that one field.  Here is the current code:

' Function FindLabel ( [NAME] )
' Stacks a label in multiple lines if
' exceeding a given length.
' Note: Not applicable to line layers.
' ------------------------------------
  dim s, sNew, i, l
  s = [NAME]
  l = Len(s)
  if l > 10 then  ' stack if exceeding this length
    sNew = Left(s,10)
    i = 11  ' scan for blank space starting from this position
    While i <= l
      if Mid(s,i,1) = " " then
        sNew = sNew & VBNewLine
        sNew = sNew & Mid(s,i,1)
      end if
      i = i + 1
    sNew = s
  end if

I need to add a field called SITEADDR and limit it's character line the same as NAME.  Any ideas?
Who is Participating?
Mark_FreeSoftwareConnect With a Mentor Commented:

ok, i don't quiet understand the question, but what you want to do can be done way easier:

give the label the width you want to have it max.

now set the property wordwrap of the label to true,
and the property autosize too

so the code looks somthing like this:

Label1.Width = 1575
Label1.WordWrap = True

you can also do this when designing

Is this question still open?
I agree with Mark, not quite sure what you're trying to do.
Can you give us some more info please?
gwr477Author Commented:
Sorry for not closing this earlier.  Thanks for your expert help.

thanks for the points, and happy coding!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.