Sub getTextFromLabelLine(lbl As Label, line As Int) As String
If line < 1 Then
Return ""
End If
Dim su As StringUtils
Dim labelText As String
Dim oldTextHigh, newTextHigh As Int
Dim textStart, textEnd As Int
Dim textLine As Int
Dim i, j As Int
labelText = lbl.text
oldTextHigh = 0
textEnd = labelText.Length
textStart = textEnd
textLine = 0
i = -1
Do While i < labelText.Length
i = i + 1
j = i
Do While (i < labelText.Length) AND (labelText.CharAt(i) <> " ")
i = i + 1
Loop
newTextHigh = su.MeasureMultilineTextHeight(lbl, labelText.SubString2(0, i))
If newTextHigh > oldTextHigh Then
oldTextHigh = newTextHigh
textLine = textLine + 1
If textLine = line Then
textStart = j
End If
If textLine > line Then
textEnd = j
Exit
End If
End If
Loop
Return labelText.SubString2(textStart, textEnd)
End Sub