Well I have been able to figure this out but what I want to do is make my string have a new line after 20 chars. I know how to find how many chars the string has but not how to insert environment.newline at 20 chars.
I am using this to find the str开发者_运维百科ing length
If string.Length > 20 then
'Need to be able to insert environment.newline at 20 chars
Else
'Normal string
End If
You need to use a loop: (Tested)
For index As Integer = 20 * (str.Length \ 20) To 0 Step -20
str = str.Insert(index, Environment.NewLine)
Next
If the string can be very long, you should use a StringBuilder instead.
If string.Length > 20 Then sTest = sTest.Insert(19, Environment.NewLine) End If
EDIT:
I think the index should be 19, or it could be 20, you might need to experiment with that.
精彩评论