By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,197 Members | 1,210 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

Add New Line in MessageBox

P: 6
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.
Sep 14 '07 #1
Share this Question
Share on Google+
12 Replies


Expert 5K+
P: 8,434
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.)
Sep 14 '07 #2

pureenhanoi
100+
P: 175
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"
Sep 14 '07 #3

Expert 5K+
P: 8,434
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.
Sep 14 '07 #4

pureenhanoi
100+
P: 175
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.
Sep 15 '07 #5

Expert 5K+
P: 8,434
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?
Sep 15 '07 #6

pureenhanoi
100+
P: 175
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.
Sep 15 '07 #7

Expert 5K+
P: 8,434
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.")
Sep 15 '07 #8

Robbie
100+
P: 180
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.
Sep 15 '07 #9

Expert 5K+
P: 8,434
... 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.
Sep 16 '07 #10

P: 6
Thanks for ur all help.
Sep 18 '07 #11

pureenhanoi
100+
P: 175
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=""0914450513"" & 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
Sep 19 '07 #12

Expert 5K+
P: 8,434
Your code will not return the desire result
That's because you didn't close the quotes. So that is not "my code". ;)
Sep 19 '07 #13

Post your reply

Sign in to post your reply or Sign up for a free account.