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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to force line break in Msg Box 2

Status
Not open for further replies.

srast

MIS
Nov 11, 2002
42
US
Hello all.
Does anyone have any idea how to force a line break in a Msg box? Someone suggested Alt + Enter in the code where the text for the message is entered, but that didn't work.
Any help would be appreciated.
Thanks.
Steve
 
Hi Steve!

You can do it this way:

"First part of message" & vbCrLf & "Last part of message"

hth
Jeff Bridgham
bridgham@purdue.edu
 
Jeff,
Thanks so much! It works great.
Two questions though.
1) What does "VbCrLf" stand for, and where could I find more such propreties, and what they stand for? (in the Microsoft help section?)
2) My line of code for the mesage box method is too long.
How do you put a line break there? I thought it was the underscore character (_), but that doesn't seem to work.
Thnaks again!
Steve
 
vbCrLf

the vb is because it's a Visual Basic intrinsic constant
Cr Carriage Return
Lf Line Feed

If your break is in a string you need '&' as well

MsgBox "Hello how " & _
"are you today", _
vbOKCancel, "Greeting"

if not...

MsgBox "Hello how are you today", _
vbOKCancel, "Greeting"

There are two ways to write error-free programs; only the third one works.
 
Hi!

Just to add a little to GHolden's excellent post. Make sure that you have a space before the _ or it will not work. And, to find more constants, open VB Help and click on the contents tab. Find Visual Basic Language Reference and click on that. One of the choices should be Constants. vbCrLf is found under Miscellaneous, but there are many categories.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Good point, well made, Jeff

There are two ways to write error-free programs; only the third one works.
 
Thanks GHolden.
Thanks Jeff.
You've both been very helpful.
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top