I just need to know an easy way to wrap the text in my console application I have 5 lines of text I was displayed like a nice clean paragraph no matter the size of the window.:afrog:
Printable View
I just need to know an easy way to wrap the text in my console application I have 5 lines of text I was displayed like a nice clean paragraph no matter the size of the window.:afrog:
The Console.WindowWidth property will tell you how many characters wide the window is, so you can break your text up into substrings of that length.
Thanks for the reply but I ended up just taking a shorter route so it all worked out. I'm still a newbie =P I'm only on my 8th week of class on vb.net and I'm a first time programmer and we havn't covered console.windowwidth yet so I don't really know what to do with it but thanks anyways.
vb.net Code:
Private Sub WriteWithWrap(ByVal text As String) Dim maxCharCount As Integer = Console.WindowWidth Do If text.Length > maxCharCount Then 'Write the first line of text. Console.WriteLine(text.Substring(0, maxCharCount)) 'Remove the characters that have already been written. text = text.Substring(maxCharCount) Else 'Write the entire text and exit the loop. Console.WriteLine(text) Exit Do End If Loop End Sub