這是你在找什麼?
Sub Main()
Dim testMessage As String
testMessage = "For future reference, I could see this being used in order to create a similar script within a web page in order to automatically populate data fields from an RSS or .xml feed without breaking the template and either forcing a font to shrink to fit the entire field, or creating a line break in the middle of a word."
PrintMessage(testMessage, 30)
Console.ReadLine()
End Sub
Sub PrintMessage(Message As String, Length As Integer)
Dim currentLength = 0
Dim words As Array
words = Split(Message, " ")
For Each word As String In words
If currentLength + word.Length > Length Then
Console.Write(ControlChars.Tab & currentLength)
Console.WriteLine()
currentLength = 0
End If
Console.Write(word & " ")
currentLength += word.Length
Next
Console.Write(ControlChars.Tab & currentLength)
End Sub
產生這樣的輸出:
For future reference, I could see 28
this being used in order to create a 29
similar script within a web page in 29
order to automatically populate 28
data fields from an RSS or .xml feed 29
without breaking the template and 29
either forcing a font to shrink to 28
fit the entire field, or creating a 29
line break in the middle of a word. 29