Putting more than one paragraph into a message box

O

Oz Springs

Is it possible to put a paragraph mark into a message box? I have tried
using Chr(13)_ with and without + and double quotes and neither work.

Also, is Chr(13) appropriate for PC users? I am using Word 2004, but the
template is mainly for Pcers.



Thanks for any help




Oz
 
J

JE McGimpsey

Oz Springs said:
Is it possible to put a paragraph mark into a message box? I have tried
using Chr(13)_ with and without + and double quotes and neither work.

Also, is Chr(13) appropriate for PC users? I am using Word 2004, but the
template is mainly for Pcers.

one way:

MsgBox "This is the first line." & vbNewLine & vbNewLine & _
"This is the second line."

vbNewLine will be resolved appropriately for Mac or win.
 
O

Oz Springs

Thank you very much. That¹s the last bit of this template - well, until the
people want it amended...

Kind regards



Oz
 
P

Paul Berkowitz

one way:

MsgBox "This is the first line." & vbNewLine & vbNewLine & _
"This is the second line."

vbNewLine will be resolved appropriately for Mac or win.

Actually - just as regular Word documents always use Chr(13) = vbCr as line
ends (paragraph ends) on both Mac and Windows, so MsgBox always takes
Chr(10) = vbLf as line ends on both Mac and Windows.

MsgBox "This is the first line." & vbLf & vbLf & _
"This is the second line."

works on the Mac as on Windows.

Once again, it's only for .txt files that you need vbNewLine to
differentiate between Mac and Windows. It's handy that MsgBox understands
what you mean anyway...


--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
J

JE McGimpsey

Paul Berkowitz said:
Actually - just as regular Word documents always use Chr(13) = vbCr as line
ends (paragraph ends) on both Mac and Windows, so MsgBox always takes
Chr(10) = vbLf as line ends on both Mac and Windows.

NO, in MacVBA, for some hosed up reason, vbLF = Chr(13). but only
sometimes. From the VBE Immediate Window:

?asc(vbCr), asc(vbLF)
Mac: 13 13
Win: 13 10

?asc(left(vbCrLf,1)),asc(mid(vbCrLf,2))
Mac: 13 10
Win: 13 10

?len(vbNewLine), asc(left(vbNewLine,1)), asc(mid(vbNewLine),2))
Mac: 1 13
Win 2 13 10


The second one is particularly egregious since Mac VBA Help says vbCrLf
= Chr(13) + Chr(13)

I'd prefer to use vbNewLine, which, if MS stays consistent (a huge "if",
I know), will always work on both platforms. That way I only have to
remember one constant, not four. Especially as VBA starts to become a
legacy language.
 
P

Paul Berkowitz

NO, in MacVBA, for some hosed up reason, vbLF = Chr(13). but only
sometimes. From the VBE Immediate Window:

?asc(vbCr), asc(vbLF)
Mac: 13 13
Win: 13 10

?asc(left(vbCrLf,1)),asc(mid(vbCrLf,2))
Mac: 13 10
Win: 13 10

?len(vbNewLine), asc(left(vbNewLine,1)), asc(mid(vbNewLine),2))
Mac: 1 13
Win 2 13 10


The second one is particularly egregious since Mac VBA Help says vbCrLf
= Chr(13) + Chr(13)

I'd prefer to use vbNewLine, which, if MS stays consistent (a huge "if",
I know), will always work on both platforms. That way I only have to
remember one constant, not four. Especially as VBA starts to become a
legacy language.


Hmmm. But this works:

MsgBox "This is the first line." & Chr(10) & Chr(10) & _
"This is the second line."


But then so does this (although the OP said it doesn't) - in 2004 anyway:

MsgBox "This is the first line." & Chr(13) & Chr(13) & _
"This is the second line."

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
J

JE McGimpsey

Paul Berkowitz said:
But then so does this (although the OP said it doesn't) - in 2004 anyway:

MsgBox "This is the first line." & Chr(13) & Chr(13) & _
"This is the second line."

Well, that had me confused, too.
 
P

Paul Berkowitz

Is it possible to put a paragraph mark into a message box? I have tried
using Chr(13)_ with and without + and double quotes and neither work.

Oz, do you mean showing us _exactly_ what your MsgBox code looks like?

You didn't by any chance try to concatenate Chr(13) to the rest of the text
using + instead of & , did you? You need "&" operator for strings: "+" is
just for numbers in VBA.

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

Please "Reply To Newsgroup" to reply to this message. Emails will be
ignored.

PLEASE always state which version of Microsoft Office you are using -
**2004**, X or 2001. It's often impossible to answer your questions
otherwise.
 
O

Oz Springs

The code looks like this:

Msg = "Please enter contact details here." & vbNewLine & vbNewLine & "If you
have more...²

Apologies: I was using as an example some concatenated text which contained
Chr(13)

My message box works fine now that I know about vbNewLine and &

Kind regards



Oz
 

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