How to CRLF in MessageBox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SoftwareTester
    New Member
    • Jan 2008
    • 13

    #1

    How to CRLF in MessageBox

    I would like to know how to put text over 2 (or several) lines in a messageBox

    I tried MessageBox.Show ("Text-1" + "\\r\\n" + "text-2"); but that doesn't work
  • vekipeki
    Recognized Expert New Member
    • Nov 2007
    • 229

    #2
    Why the double backslash?

    "\r\n" should work, but a better way would be to use Environment.New Line.

    Comment

    • rvarshney
      New Member
      • Feb 2009
      • 10

      #3
      When you say "\\r\\n" , it should print "\" instead of "\\". so they are treated as 4 characters not the two.

      as said, Environment.New Line is the best option to cope with this.

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        Yes, the problem is your double backslashes.

        A single backslash and the following character is an escape sequence. So when you do "\\r" what you are literally doing is escaping the second backslash, so the literal string result is: "\r" What you should be doing is "\r" which is interpreted as a carriage return.

        However, I also agree with everyone else. Environment.New Line is a handy way to avoid escape sequences.

        Comment

        Working...