1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Carriage return character in VBA

Discussion in 'Software Development' started by drawde, Aug 10, 2006.

Thread Status:
Not open for further replies.
Advertisement
  1. drawde

    drawde Thread Starter

    Joined:
    Jul 28, 2006
    Messages:
    18
    THis is probably a very stupid question, but I have just begun teaching myself VBA in Microsoft Office 2003.

    I am trying to use the MsgBox function in Word to display a message box, however I need to make the message run over two lines of text. The help file says "If prompt consists of more than one line, you can separate the lines using a carriage return character (Chr(13)), a linefeed character (Chr(10)), or a carriage return - linefeed character combination (Chr(13) & Chr(10)) between each line.

    This means nothing to me - I have experimented with typing (Chr(13) within my text, but it just displays this in my message box text.

    Can anyone clarify what I have to type, or give me an example of what it should look like?

    Thanks

    drawde
     
  2. OBP

    OBP Trusted Advisor

    Joined:
    Mar 8, 2005
    Messages:
    18,834
    The ASCII characters have to be included in your text but outside of any quote marks, so to include a return in your text you need something like this
    "this bit is text" & CHR$(13) & "this bit is more text"
     
  3. drawde

    drawde Thread Starter

    Joined:
    Jul 28, 2006
    Messages:
    18
    worked a treat! thanks!
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/491067