Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals 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 needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:
Microsoft Certified Partners -
https://partner.microsoft.com/global/30000104Microsoft Advisory Services -
http://support.microsoft.com/gp/advisoryserviceFor more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
The constants referred to in the "Summary" section are listed in the following table.
Constant Definition
-------------------------------------------------------------------
vbBack A backspace character [Chr(8)]
vbCr A carriage return [Chr(13)]
vbCrLf A carriage return and line feed [Chr(13) + Chr(10)]
vbLf A linefeed [Chr(10)]
vbNewLine A platform-specific new line character, either
[Chr(13) + Chr(10)] or [Chr(13)]
vbNullChar A null character of value 0 [Chr(0)]
vbNullString A string of value 0 [no Chr code]; note that this is
not the same as ""
vbTab A tab character [Chr(9)]
You can use these constants anywhere in Visual Basic code that you want
them to appear. For example, you can use them to display a multi-line
message in a message box, as in the following example:
MsgBox "Hello" & vbCr & "World!"
Make sure that you do not enclose the constants in quotation marks; if
you do, the constants appear in the text string instead of as the characters that they represent.
When you use these constants, you may notice the following issues.
Text Boxes and Cells
In Excel 2000, if you use these constants when you insert text into a text box or into a cell, a square character may appear in the text box or cell. This behavior occurs if you use any of the following constants:
- vbBack
- vbCr
- vbCrLf
- vbNewLine
- vbTab
Additionally, the following behaviors can occur under the following conditions:
Message Boxes (MsgBox)
All of the constants listed in this article work correctly when used in a
MsgBox, with the exception of the following:
- If you use the vbBack constant, a square character appears in the message box. For example, if you run the following line of code
MsgBox "AAA" & vbBack & "BBB"
the message box displays the following message:
AAA[square character]BBB
- If you use the vbNullChar constant, text following the constant is cut off.