well i'm trying to make a textbox multiline with a limit of 39 chars per line.
the divison is made with the conditions of:

-if the line have a space it divides with the first space.
-if the line dont have spaces it put a "-" and it pass to the next line.

the problem is that i'm not reaching the result i whant :S

my code:
vb.net Code:
  1. Public Function Check_text()
  2.         Dim myLines As New List(Of String)
  3.         Dim letra As String
  4.         For Each ln As String In Me.TextBox1.Lines
  5.             If ln.Length > 39 Then
  6.                 Dim revtext As String = ReverseString(ln.Substring(0, 38).ToString)
  7.                 Dim pos As Integer
  8.                 pos = InStr(1, revtext, " ")
  9.                 If pos > 0 Then
  10.                     ' We found it.
  11.                     TargetPosition = pos
  12.                     Dim before = revtext.Substring(0, pos + 1).ToString
  13.                     Dim antes = revtext.Substring(pos, ln.Length - pos - 2).ToString
  14.                     Mid(revtext, pos, 1) = ""
  15.                     myLines.Add(ReverseString(antes))
  16.                     myLines.Add(ReverseString(before))
  17.                 Else
  18.                     letra = ln.Substring(38, 1).ToString
  19.                     myLines.Add(ln.Substring(0, 38) & "-")
  20.                     myLines.Add(letra & ln.Substring(39))
  21.                 End If
  22.             Else
  23.                 myLines.Add(ln)
  24.             End If
  25.         Next
  26.         Me.TextBox1.Clear()
  27.         Me.TextBox1.Lines = myLines.ToArray
  28.         Me.TextBox1.SelectionStart = Me.TextBox1.Text.Length
  29.         Check_text = True
  30.     End Function

ty if you could help