ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Multiline Messagebox in VBA (https://www.excelbanter.com/excel-programming/402489-multiline-messagebox-vba.html)

Joe[_46_]

Multiline Messagebox in VBA
 
Hi all,

I wanted a Multiline Messagebox in VBA.
I tried the following code but an error ("Object Required") comes.

MsgBox ("Some text" & ControlChars.NewLine & "More text")
Is it because of the .newline? How can I get a multiline msgbox?

mine is excel 2003 (SP2)


Thanks
Joe

Gary Keramidas[_2_]

Multiline Messagebox in VBA
 
try vbnewline instead of ControlChars.NewLine

--


Gary Keramidas


"Joe" wrote in message
...
Hi all,

I wanted a Multiline Messagebox in VBA.
I tried the following code but an error ("Object Required") comes.

MsgBox ("Some text" & ControlChars.NewLine & "More text")
Is it because of the .newline? How can I get a multiline msgbox?

mine is excel 2003 (SP2)


Thanks
Joe



Joe[_46_]

Multiline Messagebox in VBA
 
On Dec 10, 1:30 pm, "Gary Keramidas" wrote:
try vbnewline instead of ControlChars.NewLine

--

Gary Keramidas

"Joe" wrote in message

...



Hi all,


I wanted a Multiline Messagebox in VBA.
I tried the following code but an error ("Object Required") comes.


MsgBox ("Some text" & ControlChars.NewLine & "More text")
Is it because of the .newline? How can I get a multiline msgbox?


mine is excel 2003 (SP2)


Thanks
Joe- Hide quoted text -


- Show quoted text -


Thanks Gary.. It worked...

Regards
Joe

Rick Rothstein \(MVP - VB\)

Multiline Messagebox in VBA
 
Simply use one of the built-in VBA constants to move to the next line....

MsgBox "Some text" & vbNewLine & "More text"

or...

MsgBox "Some text" & vbCrLf & "More text"

or even....

MsgBox "Some text" & vbLf & "More text"

or even....

MsgBox "Some text" & vbCr & "More text"

VBA seems to be tolerant of almost anything that says 'go to another line'.

Rick


"Joe" wrote in message
...
Hi all,

I wanted a Multiline Messagebox in VBA.
I tried the following code but an error ("Object Required") comes.

MsgBox ("Some text" & ControlChars.NewLine & "More text")
Is it because of the .newline? How can I get a multiline msgbox?

mine is excel 2003 (SP2)


Thanks
Joe



Jon Peltier

Multiline Messagebox in VBA
 
I read recently that vbNewLine was slightly faster than vbCrLf. vbCr and
vbLf may not give the same results.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Rick Rothstein (MVP - VB)" wrote in
message ...
Simply use one of the built-in VBA constants to move to the next line....

MsgBox "Some text" & vbNewLine & "More text"

or...

MsgBox "Some text" & vbCrLf & "More text"

or even....

MsgBox "Some text" & vbLf & "More text"

or even....

MsgBox "Some text" & vbCr & "More text"

VBA seems to be tolerant of almost anything that says 'go to another
line'.

Rick


"Joe" wrote in message
...
Hi all,

I wanted a Multiline Messagebox in VBA.
I tried the following code but an error ("Object Required") comes.

MsgBox ("Some text" & ControlChars.NewLine & "More text")
Is it because of the .newline? How can I get a multiline msgbox?

mine is excel 2003 (SP2)


Thanks
Joe





Rick Rothstein \(MVP - VB\)

Multiline Messagebox in VBA
 
I'm not sure about any speed advantage, but the purpose of vbNewLine is that
it is a platform (Windows or Mac) specific newline character or character
sequence. That is, in Windows, vbNewLine is the same as vbCrLf; however, on
a Mac, vbNewLine is the same as vbCr. That means if you are trying to inject
a newline character sequence into a string of text, using vbNewLine relieves
you of having to know what operating system your code will be run on. With
that said, it is my understanding that the MessageBox statement will treat
any of vbNewLine, vbCrLf, vbCr and vbLf all the same... as a newline
character (sequence) no matter which operating system the code is run on.
While the following link is directed at XL2000, the part described above is,
again my understanding, universally applicable for the various Office
products as well as the compiled version of VB.

http://support.microsoft.com/kb/211774

Rick


"Jon Peltier" wrote in message
...
I read recently that vbNewLine was slightly faster than vbCrLf. vbCr and
vbLf may not give the same results.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Rick Rothstein (MVP - VB)" wrote in
message ...
Simply use one of the built-in VBA constants to move to the next line....

MsgBox "Some text" & vbNewLine & "More text"

or...

MsgBox "Some text" & vbCrLf & "More text"

or even....

MsgBox "Some text" & vbLf & "More text"

or even....

MsgBox "Some text" & vbCr & "More text"

VBA seems to be tolerant of almost anything that says 'go to another
line'.

Rick


"Joe" wrote in message
...
Hi all,

I wanted a Multiline Messagebox in VBA.
I tried the following code but an error ("Object Required") comes.

MsgBox ("Some text" & ControlChars.NewLine & "More text")
Is it because of the .newline? How can I get a multiline msgbox?

mine is excel 2003 (SP2)


Thanks
Joe







All times are GMT +1. The time now is 07:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com