Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MsgBox() Function wont continue text onto next line 1

Status
Not open for further replies.

Sesami

Programmer
Joined
Jan 17, 2004
Messages
1
Location
US
I can't seem to get text to continue on to the next line. In other words, I need to create a list of things in a message box, instead of creating one long line. For example, I need to display BMI ranges like this:

<18.5 Underweight
18.5-25 Normal
25-30 Overweight
ect...

The message box displays it like this: &quot;<18.5 Underweight 18.5-25 Normal 25-30 Overweight&quot;

I would really appreciate it if anyone could give me some tips on how to fix this problem. Thanks a lot.

Sesami
 
This should help

Dim myText As String

Dim wrap As String = chr(10) & chr(13)

myText = &quot;<18.5 Underweight&quot; & wrap & &quot;18.5-25 Normal&quot; & wrap & &quot;25-30 Overweight&quot;

MsgBox(myText, MsgBoxStyle.OKOnly)

Good luck.


Becca

Somtimes, the easy answer is the hardest to find. :)

Still under construction ...
 
I'm new to VB.net myself. I have always used the constant vbCrLf, I quess I saw it in a code example somewhere in the net when I first started with VB.net.

From the good ol' Object Browser:

Public Const vbCrLf As String = Microsoft.VisualBasic.Constants.vbCrLf
Member of Microsoft.VisualBasic.Constants

Summary:
vbCrLf - Chr(13) + Chr(10) Carriage return/linefeed character combination.


The code could be simplified as follows:

Code:
Dim myText As String
myText = &quot;<18.5 Underweight&quot; & vbCrLf & &quot;18.5-25 Normal&quot; & vbCrLf & &quot;25-30 Overweight&quot;
MsgBox(myText, MsgBoxStyle.OKOnly)

I have always used this constant and just now found that it is part of the Microsoft.VisualBasic.Constants namespace. These constants are declared as Public, therefore you don't need to explicitly qualify the namespace and can use them anywhere in your code.

Here is a link to a list of the constants in the namespace:


-Stephen Paszt
 
I use vbNewLine
Code:
MsgBox("<18.5 Underweight" & vbNewLine & "18.5-25 Normal" & vbNewLine & "25-30 Overweight")
 
jonbatts - If you want to use the .NET Framework you should use:
Code:
        MessageBox.Show("Hello" & System.Environment.NewLine & "Everybody")

--------------------------------------------------------------------------------------------------------------------------------------------

Need help finding an answer?

Try the search facility ( or read FAQ222-2244 on how to get better results.
 
actually your all wrong except ca8msm who is very close ubt I think this is better.

Code:
controlchars.crlf is the new way to go.

vbcrlf is the old way and is bound to disappear sometime soon.

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
There's no such thing as a winnable war - Sting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top