Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Line Feed in VBA

Line Feed in VBA

What is the command to have VBA break up a block of text? i.e.
Var = "This Block of text is " & [new line here] & "too long for a single line".

What VBA code will break the text up into two lines when it comes up on the form or in a report?  

RE: Line Feed in VBA


Which is a VB constant for Carriage Return and Line Feed. It is shorthand named constant for the combination of Chr(13) & Chr(10).

RE: Line Feed in VBA

My recommendation: define constants in a general module like

  Public Const NL As String = vbNewLine       'New line
  Public Const DL As String = NL & NL         'New line after space
  Public Const DQ As String = """"            'Double quotes
  Public Const S12 As String = "            " '12 Spaces

and then use your own short-cut constants


Msgbox "This Works." & NL & "Good!"

Best, georgesOne

RE: Line Feed in VBA

thanks.  I had tried Chr10 and Chr13 but not together.

RE: Line Feed in VBA

How are ya PL01 . . .

You can also use the constant vbNewLine. I always have the following two constants in the declaration header of a module for global access:


Public Const NL As String = vbNewline 'new line
Public Const DL As String = NL & NL   'skip a line

As an example I'll breakup the following "Now is the time For all good men To come to The aid of their countrymen"


   Dim str As String
   str = "Now is the time" & NL & _
         "For all good men" & NL & _
         "To come to" & NL & _
         "The aid of their countrymen"
   Debug.Print str
Your Thoughts? . . .

See Ya! .  .  .  .  .  .

Be sure to see FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?  Worthy Reading! thumbsup2
Also FAQ181-2886: How can I maximize my chances of getting an answer?  Worthy Reading! thumbsup2

RE: Line Feed in VBA

OLD definitions in the mechanical typewriter/printer days:

Carriage Return: The command used to either return the carriage or printhead, to the beginning-of-line position, as in an old typewriter.  Used alone, the previously typed characters in the line, could be overtyped.

Line Feed: The command used to turn the platen forward one position.  Used alone, produces a result like...

                Line Feed here--+
Now is the time for all good men
                                to come to the aid of their country.



glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Line Feed in VBA

One can use one of the following

vbCrLf - Carriage Return and Line Feed
vbNewLine - Carriage Return and Line Feed

Say no to macros

RE: Line Feed in VBA

...thank you very much for the information.  But where are all the VBA commands conveniently indexed?  I searched high and low for them in Access help.  Is there a definitive text?  I use the two Access for Idoits books which are very good to learn from - but the indexing is completely deficient.  It's difficult to finds things in the thousand pages.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close