473,491 Members | 3,350 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How Do I Put An End Of Line Character In A TextBox

How would I put an end of line character in the second line below?

Textbox1.Text = "Hello "
Textbox1.Text =
Textbox1.Text = "World"

Thanks,
Chris Lusardi

May 16 '06 #1
10 15881
textbox1.text "Hello " & vbcrlf & vbcrlf & "World"

May 16 '06 #2
cj
I didn't know vbcrlf existed. At the top of some of my programs I have
dim crlf as string = Chr(13) & Chr(10)
guess I don't need that but now I have to type vbcrlf instead of crlf.

Ahmed wrote:
textbox1.text "Hello " & vbcrlf & vbcrlf & "World"

May 16 '06 #3
I use Ahmed's example in my code as well.

May 16 '06 #4
"cj" <cj@nospam.nospam> schrieb:
I didn't know vbcrlf existed. At the top of some of my programs I have
dim crlf as string = Chr(13) & Chr(10)
guess I don't need that but now I have to type vbcrlf instead of crlf.


No, you don't need it. Note that VB.NET has a 'ControlChars.NewLine'
constant too, and 'Environment.NewLine' will return the system's new line
character.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

May 16 '06 #5
Herfried,

I once asked you to make a testset and you told than that you had not the
time to type that.

Why are you advicing that long code, while there is that simple vbcrlf.

In C# I find the 'ControlChars.NewLine' a very good alternative for the
literal. But VB has a better solution for that.

Cor

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schreef in bericht
news:OB**************@TK2MSFTNGP05.phx.gbl...
"cj" <cj@nospam.nospam> schrieb:
I didn't know vbcrlf existed. At the top of some of my programs I have
dim crlf as string = Chr(13) & Chr(10)
guess I don't need that but now I have to type vbcrlf instead of crlf.


No, you don't need it. Note that VB.NET has a 'ControlChars.NewLine'
constant too, and 'Environment.NewLine' will return the system's new line
character.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

May 17 '06 #6
You saw it probably already, I forgot the :-)

Cor

"Cor Ligthert [MVP]" <no************@planet.nl> schreef in bericht
news:um**************@TK2MSFTNGP03.phx.gbl...
Herfried,

I once asked you to make a testset and you told than that you had not the
time to type that.

Why are you advicing that long code, while there is that simple vbcrlf.

In C# I find the 'ControlChars.NewLine' a very good alternative for the
literal. But VB has a better solution for that.

Cor

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schreef in bericht
news:OB**************@TK2MSFTNGP05.phx.gbl...
"cj" <cj@nospam.nospam> schrieb:
I didn't know vbcrlf existed. At the top of some of my programs I have
dim crlf as string = Chr(13) & Chr(10)
guess I don't need that but now I have to type vbcrlf instead of crlf.


No, you don't need it. Note that VB.NET has a 'ControlChars.NewLine'
constant too, and 'Environment.NewLine' will return the system's new line
character.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


May 17 '06 #7
cj
Is controlchars.newline available in both VB and C#? If so perhaps
Herfried is promoting using something that would be the same from
language to language. VB also has vbNewLine. Frankly everything is
getting long. I almost stuck with dimming my own, crlf, as it is 4
chars instead of vbCrLf's 6. And actually thought about using nl for
newline but it wasn't quite as obvious when reading the code. Anyway I
went with vbCrLf as it doesn't need a dim and I'll get used to it.
Cor Ligthert [MVP] wrote:
You saw it probably already, I forgot the :-)

Cor

"Cor Ligthert [MVP]" <no************@planet.nl> schreef in bericht
news:um**************@TK2MSFTNGP03.phx.gbl...
Herfried,

I once asked you to make a testset and you told than that you had not the
time to type that.

Why are you advicing that long code, while there is that simple vbcrlf.

In C# I find the 'ControlChars.NewLine' a very good alternative for the
literal. But VB has a better solution for that.

Cor

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schreef in bericht
news:OB**************@TK2MSFTNGP05.phx.gbl...
"cj" <cj@nospam.nospam> schrieb:
I didn't know vbcrlf existed. At the top of some of my programs I have
dim crlf as string = Chr(13) & Chr(10)
guess I don't need that but now I have to type vbcrlf instead of crlf.
No, you don't need it. Note that VB.NET has a 'ControlChars.NewLine'
constant too, and 'Environment.NewLine' will return the system's new line
character.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


May 17 '06 #8
"cj" <cj@nospam.nospam> schrieb:
Is controlchars.newline available in both VB and C#?
No, 'ControlChars.NewLine' is part of "Microsoft.VisualBasic.dll".
language to language. VB also has vbNewLine. Frankly everything is
getting long. I almost stuck with dimming my own, crlf, as it is 4 chars
instead of vbCrLf's 6.


Well, you could import the 'ControlChars' type and then use 'NewLine' and
'CrLf' throughout your code, without any bad performance implications.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

May 17 '06 #9
"Cor Ligthert [MVP]" <no************@planet.nl> schrieb:
I once asked you to make a testset and you told than that you had not the
time to type that.

Why are you advicing that long code, while there is that simple vbcrlf.

In C# I find the 'ControlChars.NewLine' a very good alternative for the
literal. But VB has a better solution for that.


Well, first, we have to distinguish between methods/properties to determine
the system's new line character and on getting a system-independent new line
character sequence. The first can be done using 'Environment.NewLine' in
both VB.NET and C#. For the latter there are different ways in VB.NET and
C#. In C# typically new line character sequences are embedded as escape
codes inside string literals:

\\\
string s = "Hello\r\nWorld"
///

The equivalent code in VB.NET would be

\\\
Dim s As String = "Hello" & ControlChars.CrLf & "World"
///

or alternatively

\\\
Dim s As String = "Hello" & vbCrLf & "World"
///

'vbNewLine' and 'ControlChars.NewLine' both are constants which have the
same value as 'vbCrLf'. IIRC 'vbNewLine' has been introduced in VBA once to
support /different/ newline character sequences in VBA on Windows and on the
Mac.

Personally I generally prefer 'ControlChars.NewLine' or 'vbNewLine' over
'ControlChars.CrLf' and 'vbCrLf' because its name is semantically more
meaningful and I do not care about the value of the constant too much.
However, if the exact character codes are important, then I prefer 'CrLf'
and 'vbCrLf'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

May 17 '06 #10
LOL

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schreef in bericht
news:ub**************@TK2MSFTNGP04.phx.gbl...
"Cor Ligthert [MVP]" <no************@planet.nl> schrieb:
I once asked you to make a testset and you told than that you had not the
time to type that.

Why are you advicing that long code, while there is that simple vbcrlf.

In C# I find the 'ControlChars.NewLine' a very good alternative for the
literal. But VB has a better solution for that.


Well, first, we have to distinguish between methods/properties to
determine the system's new line character and on getting a
system-independent new line character sequence. The first can be done
using 'Environment.NewLine' in both VB.NET and C#. For the latter there
are different ways in VB.NET and C#. In C# typically new line character
sequences are embedded as escape codes inside string literals:

\\\
string s = "Hello\r\nWorld"
///

The equivalent code in VB.NET would be

\\\
Dim s As String = "Hello" & ControlChars.CrLf & "World"
///

or alternatively

\\\
Dim s As String = "Hello" & vbCrLf & "World"
///

'vbNewLine' and 'ControlChars.NewLine' both are constants which have the
same value as 'vbCrLf'. IIRC 'vbNewLine' has been introduced in VBA once
to support /different/ newline character sequences in VBA on Windows and
on the Mac.

Personally I generally prefer 'ControlChars.NewLine' or 'vbNewLine' over
'ControlChars.CrLf' and 'vbCrLf' because its name is semantically more
meaningful and I do not care about the value of the constant too much.
However, if the exact character codes are important, then I prefer 'CrLf'
and 'vbCrLf'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

May 17 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
16228
by: Nurchi BECHED | last post by:
Hello, All! I have created an application with a multiline textbox on the form. When I press a button, it has to show something and then break the line and show something else. I tried "\n",...
6
6593
by: Maziar Aflatoun | last post by:
Hi, I have a little application that reads a text file line-by-line and processes each line depending on the CVS values. Now I want to change my program to capture this from a textbox. How do...
4
6090
by: david | last post by:
I have trouble to write paragragh with newlines in a multiline textbox control in ASP.NET form. I would like to display an instruction in textbox in the web form. But I do not know how to type...
22
4482
by: DraguVaso | last post by:
Hi, For my application I need the following behavior: When I press F4 the cursor has to move to the next line in my multiline textbox which begins with "0". Finding lines starting with 0 isn't...
0
848
by: Eric | last post by:
Visual C++ 2005 Express MVP's and experience programmer's only please!... I need to get the number of lines in a textbox so I can insert them into a listview. The text comes from my database...
0
819
by: Eric | last post by:
Visual C++ 2005 Express MVP's and experience programmer's only please!... I need to get the number of lines in a textbox so I can insert them into a listview. The text comes from my database...
0
974
by: Eric | last post by:
Visual C++ 2005 Express MVP's and experience programmer's only please!... I need to get the number of lines in a textbox so I can insert them into a listview. The text comes from my database...
0
872
by: Eric | last post by:
Visual C++ 2005 Express MVP's and experience programmer's only please!... I need to get the number of lines in a textbox so I can insert them into a listview. The text comes from my database...
6
27832
by: poojo hackma | last post by:
How is the New Line character written to the TextBox field (TextBox.Multiline=True)? For example: TextBox1.Text = "Line 1\nLine 2"; Above does not produce 2 lines in the TextBox1. Simple...
0
7118
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7157
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
7192
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7364
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
5452
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,...
1
4886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
282
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.