[RESOLVED] [2005] Line limit.
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:
Public Function Check_text()
Dim myLines As New List(Of String)
Dim letra As String
For Each ln As String In Me.TextBox1.Lines
If ln.Length > 39 Then
Dim revtext As String = ReverseString(ln.Substring(0, 38).ToString)
Dim pos As Integer
pos = InStr(1, revtext, " ")
If pos > 0 Then
' We found it.
TargetPosition = pos
Dim before = revtext.Substring(0, pos + 1).ToString
Dim antes = revtext.Substring(pos, ln.Length - pos - 2).ToString
Mid(revtext, pos, 1) = ""
myLines.Add(ReverseString(antes))
myLines.Add(ReverseString(before))
Else
letra = ln.Substring(38, 1).ToString
myLines.Add(ln.Substring(0, 38) & "-")
myLines.Add(letra & ln.Substring(39))
End If
Else
myLines.Add(ln)
End If
Next
Me.TextBox1.Clear()
Me.TextBox1.Lines = myLines.ToArray
Me.TextBox1.SelectionStart = Me.TextBox1.Text.Length
Check_text = True
End Function
ty if you could help :)