WD: Using MsgBox Statement to Display Multiple Lines of Text

Last reviewed: February 11, 1998
Article ID: Q81788
The information in this article applies to:
  • Microsoft Word for Windows, versions 1.0, 1.1, 1.1a, 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Microsoft Word 97 for Windows
  • Word for the Macintosh, versions 6.0, 6.0.1, 6.0.1a
  • Microsoft Word 98 Macintosh Edition

SUMMARY

In Microsoft Word, you can use the MsgBox command to post a message or the value of a variable. This article discusses how to display more than one line of text within a message box.

MORE INFORMATION

To post more than one line of information, you use character 13 or "Chr$(13)", to insert a paragraph mark within the message box.

The following macro command posts the contents of the variables strRed, strGreen and strBlue on separate lines of a message box:

      MsgBox strRed + Chr$(13) + strGreen + Chr$(13) + strBlue

Assuming the contents of the variables equate to Red, Green, and Blue, the above macro command results in a message box that displays the following lines of text:

   Red
   Green
   Blue

If the text you want to display is of numeric value, you can use the Str$() function to return the string representation. For example, the following macro posts the numbers 1 and 2, on seperate lines, in a message box:

   MsgBox Str$(1) + Chr$(13) + Str$(2)

The following macro command demonstrates the use of character 13 to display two lines of literal text in a message box:

      MsgBox "Line One of the message box." + Chr$(13) + "Line Two."

This macro command results in a message box that displays the following lines of text:

   Line One of the message box.
   Line Two.

REFERENCES

"Using WordBasic," by WexTech Systems and Microsoft, page 257


Additional query words: new line Chr$ MsgBox message box

Keywords : kbmacroexample kbwordvba macword ntword winword winword2 word6 word7 word8 word95 word97 wordnt macword98 kbmacro
Version : WINDOWS:1.0,1.1,1.1a,2.0,2.0a,2.0a- CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a,97; MACINTOSH:6.0,6.0.1,6.0.1a,98
Platform : MACINTOSH Win95 WINDOWS winnt
Issue type : kbhowto kbinfo


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 11, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.