Knowledge Base

How to Enter a Second Line in a Message Box

Article ID: 124213

Article Last Modified on 10/11/2006


APPLIES TO


This article was previously published under Q124213

SUMMARY

In a Microsoft Visual Basic for Applications macro (Sub procedure), to display more than one line of text in a message box, use the line feed character (character code 13) as in the following sample code.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

Sample Visual Basic Procedure

  1. Type the following macro into a new module sheet:
          Sub Test()
              MsgBox prompt:="Line1" & Chr(13) & "Line2"
          End Sub
    						
  2. Run the "Test" macro.
A message box appears with the following text:

Line1
Line2

REFERENCES

For additional information about getting help with Visual Basic for Applications, please see the following article in the Microsoft Knowledge Base:

163435 VBA: Programming Resources for Visual Basic for Applications


Additional query words: 97 XL97 XL7 XL5 XL

Keywords: kbdtacode kbhowto kbprogramming KB124213