gwr477
asked on
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
else
sNew = sNew & Mid(s,i,1)
end if
i = i + 1
Wend
else
sNew = s
end if
I need to add a field called SITEADDR and limit it's character line the same as NAME. Any ideas?
' 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
else
sNew = sNew & Mid(s,i,1)
end if
i = i + 1
Wend
else
sNew = s
end if
I need to add a field called SITEADDR and limit it's character line the same as NAME. Any ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry for not closing this earlier. Thanks for your expert help.
thanks for the points, and happy coding!
I agree with Mark, not quite sure what you're trying to do.
Can you give us some more info please?