Add New Line in MessageBox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KalupaPaluku
    New Member
    • Sep 2007
    • 6

    Add New Line in MessageBox

    Hi, everybody! I would like to ask for your helps to solve this problem -- How to add new line in MessageBox, using VB 2005. i try using '&vbnewline&' , but still can't work.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by KalupaPaluku
    Hi, everybody! I would like to ask for your helps to solve this problem -- How to add new line in MessageBox, using VB 2005. i try using '&vbnewline&' , but still can't work.
    Can you show us the code you have tried? (The vbNewLine constant is used in VB6 and earlier, but may not be correct in VB2005.)

    Comment

    • pureenhanoi
      New Member
      • Mar 2007
      • 175

      #3
      Originally posted by KalupaPaluku
      Hi, everybody! I would like to ask for your helps to solve this problem -- How to add new line in MessageBox, using VB 2005. i try using '&vbnewline&' , but still can't work.
      vbNewLine maybe special character used in files. To add new line in msgbox, let the message text = "The first line text" & vbCrLf & " The second line text"

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by pureenhanoi
        vbNewLine maybe special character used in files. To add new line in msgbox, let the message text = "The first line text" & vbCrLf & " The second line text"
        As I said, I don't know how it works in VB2005. But in VB6, I would always recommend using vbNewLine rather than vbCrLf. They actually have the same value, but vbNewLine has the more meaningful name, especially for newbies.

        Let's face it, unless you've been dealing with computers for a while, Cr and Lf don't mean anything. As a result, VbCrLf just looks like a random jumble of letters. A meaningful name is much easier to remember.

        Comment

        • pureenhanoi
          New Member
          • Mar 2007
          • 175

          #5
          Originally posted by Killer42
          Let's face it, unless you've been dealing with computers for a while, Cr and Lf don't mean anything. As a result, VbCrLf just looks like a random jumble of letters. A meaningful name is much easier to remember.
          I dont think Cr and Lf is a random jumble of letters. Cr = Carriage Return; Lf = Line Feed; those are common words used in info-tech.

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by pureenhanoi
            I dont think Cr and Lf is a random jumble of letters. Cr = Carriage Return; Lf = Line Feed; those are common words used in info-tech.
            My point was that while you and I know that, a newbie is more likely to recognise what "newline" means. It's just simpler, that's all.

            As an analogy, anywhere you use the letter "A", you could also use Chr(65) - but why would you?

            Comment

            • pureenhanoi
              New Member
              • Mar 2007
              • 175

              #7
              Originally posted by Killer42
              My point was that while you and I know that, a newbie is more likely to recognise what "newline" means. It's just simpler, that's all.

              As an analogy, anywhere you use the letter "A", you could also use Chr(65) - but why would you?
              Users should learn how to use common constants, if they use vbNewLine only, they cant understand why some codes use vbCrLf. ( i belive that, vbCrLf is use more commonly than vbNewLine in breaking text message).
              Your example about "A" character and Chr(65), thats was not perfect. "A" is the mainly used character, Chr(65) is coding used, while vbCrLf is mainly used to break text(i belive that) and vbNewLine is mainly used in breaking line in file.
              They are diffrent and cannot to be compared.
              And, some time, use Chr() making program work well, while use intrinsic character making program goes fault.
              Example:
              you need send parameter for a shell command. If parameter has some Space, so you must quote it by ( " ) charater. But ( " ) character is used to quote string in Vb, so you must use Chr(34) instead of ( " ) in parameter when sending.

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                I still stand by what I said. Given two alternatives that produce the same result, you might as well use the one that's easier to read, especially for newbies.

                And you example is also flawed.It is perfectly simple to include double quotes in a string (or parameter) which is delimited by the same character. For example Debug.Print Ucase("This string has a ""quote"" character or two in it.")

                Comment

                • Robbie
                  New Member
                  • Mar 2007
                  • 180

                  #9
                  Originally posted by Killer42
                  It is perfectly simple to include double quotes in a string (or parameter) which is delimited by the same character. For example Debug.Print Ucase("This string has a ""quote"" character or two in it.")
                  But then that goes against your point of making it look simpler to people new to VB. :P

                  Example:
                  I think
                  Text = "Filename is """+fname+" ""."
                  looks much worse than
                  Text = "Filename is "+chr(34)+fname +chr(34)+"."

                  The first line looks more like a random collection of text and speech-marks. The second one
                  lets you easily see the separate parts.

                  Anyway, we're kinda getting off-topic here.
                  In response to 'Add New Line in MessageBox', I don't use VB2005, so I can't help. But I would stand by using vbCrLf (or vbNewline, although I didn't know about that constant until a few minutes ago when I read it here - I'm more used to using CR and LF from other languages. Or just chr(13) and chr(10).

                  I do have a related question though. How can you put a new-line inside a ToolTip? I've tried many combinations of CR, LF, \n, /n... all to no avail. This is on VB6 by the way.

                  Comment

                  • Killer42
                    Recognized Expert Expert
                    • Oct 2006
                    • 8429

                    #10
                    Originally posted by Robbie
                    ... How can you put a new-line inside a ToolTip?
                    I don't think you can. It looks as though it's treated much like a Textbox without Multiline turned on. VB probably just wraps it as required by circumstances.

                    Comment

                    • KalupaPaluku
                      New Member
                      • Sep 2007
                      • 6

                      #11
                      Thanks for ur all help.

                      Comment

                      • pureenhanoi
                        New Member
                        • Mar 2007
                        • 175

                        #12
                        Originally posted by Killer42
                        I still stand by what I said. Given two alternatives that produce the same result, you might as well use the one that's easier to read, especially for newbies.

                        And you example is also flawed.It is perfectly simple to include double quotes in a string (or parameter) which is delimited by the same character. For example Debug.Print Ucase("This string has a ""quote"" character or two in it.")
                        You are lucky at this time. But, what do you say about this context:
                        I want send an command through COM port. The command need ending with Chr(13) & Chr(10).

                        Dim atCommand As String

                        is this yours idea: atCommand = "at+cmgs=""0914 450513"" & Chr(13) & Chr(10)
                        and this is my idea: atCommand= "at+cmgs=" & Chr(34) & "0914450513 " & Chr(34) & Chr(13) & Chr(10)
                        Your code will not return the desire result

                        Comment

                        • Killer42
                          Recognized Expert Expert
                          • Oct 2006
                          • 8429

                          #13
                          Originally posted by pureenhanoi
                          Your code will not return the desire result
                          That's because you didn't close the quotes. So that is not "my code". ;)

                          Comment

                          Working...