troubleshooting Question

Putting line breaks in a string if it's too long

Avatar of andy_entchev
andy_entchev asked on
Visual Basic.NET
4 Comments1 Solution244 ViewsLast Modified:
Hello, experts!
I want to spread a string across multiple lines if it's longer than 40 characters.
In case the string is too long, the last word should have a vbCrLf inserted before it, so it appears on a new line. It's like what Word does when you're writing something and it won't fit on that line, so it brings the whole word on the next line.
As a final result, the string should have vbCrLf's inserted in the appropriate places.

So say the string was: "AAAAAA BBBBBBBB CCCCCC DDDDDDDDDDDDD"
The new string should be: "AAAAAA BBBBBBBB CCCCCC" & vbCrLf & "DDDDDDDDDDDDD"

How can I do this?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros