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

Can I use a new line in a visual basic message box? 1

Status
Not open for further replies.

dcs619

MIS
Jun 18, 2004
4
US
Hey everyone, I have a vb message box in which I would like to insert a new line in the message part, but vbCrlf doesn't work. Is that possible to do, or do I have to like create a custom message box?

Here's my code:
Dim strAnswer As String
strAnswer = MsgBox("Would you like to save now? /* insert new line or carriage return here*/ Click cancel to never be reminded again.", _
vbYesNoCancel Or vbQuestion, "AutoSave activated")
If strAnswer = ...

Thanks for the help.
~Clarke
 
Clarke,

You need to set the messagebox's multiline property to true.

After this is done the vbCrLf will work properly.

-Sean
 
Yep
Code:
"Would you like to save now?" & vbcrlf & "Click cancel to never be reminded again."
 
I'm unfamiliar with a multiline property in a msgbox. Sean, could you be referring to a text box control? Clarke, SonOfEmidec's string is what I use, and it works for me.

Bob
 
SeanGriffin,

Where exactly do you set a messageboxes multiline property to true?

As far as I know (MsgBox) is a function and not an object and thus does not have any properties.

The example SonOfEmidec1100(strange nick) posted should work everytime.
 
For more elegance in message boxes vbTab also works to indent lines

eg:-

Code:
msgbox "There are three options available:-" & vbCrlf & vbCrlf & vbTab & "1" & vbCrlf & vbTab  & vbCrlf & vbTab & "2"  & vbCrlf & vbTab & "2"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top