Question Regarding MsgBox

JJ-UK

New member
Joined
Feb 21, 2008
Messages
2
Programming Experience
Beginner
Sorry if I have posted this in the wrong section. I'm still learning VB.NET and I am stuck on what will probably have an easy solution.

OK, I know how to implement new lines in the message box, but I am rather puzzled by trying to figure out how to set so many characters on each line, so that it will all be even. It's quite hard to explain, but hopefully you understand what I mean. It's hard to judge when to insert a new line.

Here is an example of how my message box turns out:

Here is a sentence. Here is
another. This sentence has more character but is not
spaced out right.


Thanks for reading!
 
For your limited example I don't think that is something easy to do with the default messagebox form. If you have large text without linefeeds the messagebox will adjust to some fixed width and all the text will flow nicely. But if you put the short text you have in one string without linefeed it isn't long enough to fill even a single line of maxwidth in default messagebox. To split it up manually you would have base calculation of full string length, decide how many lines you wanted to determine the ideal index to place linefeeds, then find the word split nearest ideal index and insert linefeed there.
Another better option is creating your own dialog (there's dialog form template), and control the fixed width yourself before showing it. In this case you would as the default messagebox have a string without linefeeds and let the text flow multiline. Set the label to show the text AutoSize=False and anchor it to follow form size.
 
Back
Top