Breaking Message Box Messages over several lines for formating - easy question I hope!

P

Patrick

Hello - I am wondering what the command is for breaking quoted text over
multiple lines for formatting in my code. An example is

MessageBox.Show("You Fool! The number of registrants cannot be 0. Please
re-enter the number of registrants.", _
"Input Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)

I would like to break the text box so it can all be viewed on the coding
screen or when the text is too much - description labels and such, as
bellow, of course, below doesn't work:

MessageBox.Show("You Fool! The number of registrants cannot be 0. _
Please re-enter the number of registrants.", "Input Error",
MessageBoxButtons.OK, _
MessageBoxIcon.Asterisk)

I really can't find an answer on how to do this. Any help would be
appreciated, and thanks!
 
M

Mike McIntyre

You may append the VB.NET new line constant like this:

MessageBox.Show("First Line" & vbCrLf & "SecondLine")

Or you can append the .NET new line constant like this:

MessageBox.Show("FirstLine" & Environment.NewLine & "SecondLine")


--
Mike

Mike McIntyre
Visual Basic MVP
www.getdotnetcode.com
 
H

Herfried K. Wagner [MVP]

Patrick said:
Hello - I am wondering what the command is for breaking quoted text over
multiple lines for formatting in my code. An example is

MessageBox.Show("You Fool! The number of registrants cannot be 0. Please
re-enter the number of registrants.", _
"Input Error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)

I would like to break the text box so it can all be viewed on the coding
screen or when the text is too much - description labels and such, as
bellow, of course, below doesn't work:

MessageBox.Show("You Fool! The number of registrants cannot be 0. _
Please re-enter the number of registrants.", "Input Error",

\\\
.... be 0." & _
"Please...
///

.... or, if you want a new line in the message box:

\\\
.... be 0." & ControlChars.NewLine & _
"Please...
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top