Torna al Thread
Public Function InserisciNewLine(ByVal str As String, ByVal maxLen As Integer) As String
If maxLen > str.Length Then
Return str
Else
If Not str(maxLen - 1).Equals(" ") Then
Dim firstSpace As Integer = str.IndexOf(" ", maxLen - 1)
If firstSpace <> -1 Then
str = str.Insert(firstSpace, Environment.NewLine).Remove(firstSpace + 2, 1)
If str.Substring(firstSpace + 2).Length > maxLen Then
Return str.Substring(0, firstSpace + 2) + InserisciNewLine(str.Substring(firstSpace + 2), maxLen)
End If
End If
End If
Return str
End If
End Function