473,406 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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.
Sep 14 '07 #1
12 60840
Killer42
8,435 Expert 8TB
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
175 100+
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
Killer42
8,435 Expert 8TB
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
175 100+
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
Killer42
8,435 Expert 8TB
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
175 100+
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
Killer42
8,435 Expert 8TB
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
180 100+
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
Killer42
8,435 Expert 8TB
... 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
Thanks for ur all help.
Sep 18 '07 #11
pureenhanoi
175 100+
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
Killer42
8,435 Expert 8TB
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

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

Similar topics

2
by: Larry Pits | last post by:
Hi All, I just want to display a message using msgbox() and I keep on getting this error message. It is invalid to show a modal dialog or form when the application is not running in...
4
by: Tressa | last post by:
I have a messagebox that I only want to pop up only if it is not already being displayed on the screen. My code is still poping up the messagebox even though it is on the screen. What am I doing...
3
by: Dan | last post by:
I am using Visual Studio .net 2003 (C#) I have a line of code like: messagebox.show("Hello"); I get the erorr message "The type or namespace name 'messagebox' could not be found (are you...
5
by: Curt Emich | last post by:
I always thought writing a simple diagnostic message in a message box would be pretty simple. Not in .NET. First, I wrote this amazingly complex piece of code: MessageBox.Show("yer mama") ...
10
by: Russ | last post by:
I've been trying to figure out how to show a simple messagebox with an OK button in my web client program (C#). I have looked at every reference to JScript and MessageBox that seemed even remotely...
10
by: Andrew | last post by:
Hi, I have a messagebox that pops up due to an event. I did it in javascript. ie. alert("Time's up. Assessment Ended"); I want to capture the OK and Cancel events of this alert messagebox. My...
5
by: Muffin | last post by:
I hope somebody can show me why I need to have a messagebox to get "random" numbers in my example. If I comment out the message box call that is in RollAbility() the numbers generated are not...
6
by: Goran Djuranovic | last post by:
Hi all, I have a VB.NET windows application that uses MDI form. When I try to delete a datagrid row from one of the MDI children forms, I use a MessageBox YesNo confirmation, which, after confirmed,...
0
by: pni8ac | last post by:
Hi, I'm having a weird problem. I use a thread to generate a lot of data in c#, and at the end of the thread I sould have a messagebox that show. If I execute the code two time, everything work...
5
by: arunbojan | last post by:
hi, I can able to read the text file, following is the code for your reference...... Dim file As New System.IO.StreamReader("E:\Dialer.txt") Dim readLine As String =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.