I am trying to display some text on screen.
If the string is too long, i want it to go to the next line.
I tried this code and it worked well,
(needing some help to simplify it, since it seems kind of redundant)
Public espacio As String = Environment.NewLine ' Espacio en string
Dim i As Integer
If Mensage.Length > 65 Then
i = Mensage.Length / 65
Select Case i
Case 1
mensage2 = Mensage.Insert(65, " -" & espacio & "")
Case 2
mensage2 = Mensage.Insert(65, " -" & espacio & "")
mensage2 = mensage2.Insert(130, " -" & espacio & "")
Case 3
mensage2 = Mensage.Insert(65, " -" & espacio & "")
mensage2 = mensage2.Insert(130, " -" & espacio & "")
mensage2 = mensage2.Insert(195, " -" & espacio & "")
Case 4
mensage2 = Mensage.Insert(65, " -" & espacio & "")
mensage2 = mensage2.Insert(130, " -" & espacio & "")
mensage2 = mensage2.Insert(195, " -" & espacio & "")
mensage2 = mensage2.Insert(260, " -" & espacio & "")
End Select
End If
but what if i want to insert the new line when there is a space available?
For example.
If this is a string.
"Hello world", and character number 65 is o, using my code it would result in
"Hell
o world"
How can i make it search to the next space so it results in
"Hello
world"
This post has been edited by Jondeate: 16 February 2013 - 08:55 PM

New Topic/Question
Reply



MultiQuote








|