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

mutil line txt box

P: n/a
Hello

For a VB novice can anyone help me with the following simple idea.

All I've got on my form is a Textbox, (mulitline = true) and a button.

When I click the button I will have some simple lines of text to be
displayed. How do I have...

Dim addLine As String = "Next Line"
Dim addLine As String = "Another Line"
TextBox1.Text = "Line one"
then the next line display Next Line
and the next display Another Line

What is the newline char? \n
Feb 13 '06 #1
Share this Question
Share on Google+
20 Replies


P: n/a
jvb
vbCrLf

Feb 13 '06 #2

P: n/a
If I write this..

TextBox1.Text = "Line one"vbCrLf
TextBox1.text "more Text"

It just overwrites the top line, with the next line, then the next.

I'm tring to display them on seperate line
1) Line one
2) more Text
3) something else

Or am i doing this wrong?

"jvb" <go*****@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
vbCrLf

Feb 13 '06 #3

P: n/a
jvb
Try this...

Me.TextBox1.Text += "Line One" & vbCrLf
Me.TextBox1.Text += "Line Two" & vbCrLf

That will give you

Line One
Line Two

Feb 13 '06 #4

P: n/a
"Jason" <ja***@someone.com> schrieb:
All I've got on my form is a Textbox, (mulitline = true) and a button.

When I click the button I will have some simple lines of text to be
displayed. How do I have...

Dim addLine As String = "Next Line"
Dim addLine As String = "Another Line"
TextBox1.Text = "Line one"
then the next line display Next Line
and the next display Another Line

\\\
Me.TextBox1.Text = _
"Line 1" & ControlChars.NewLine & _
"Line 2" & ControlChars.NewLine & _
"Line 3"
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Feb 13 '06 #5

P: n/a
> What is the newline char? \n

ControlChars.CrLf
Feb 13 '06 #6

P: n/a
Thanks, that works.
"jvb" <go*****@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
Try this...

Me.TextBox1.Text += "Line One" & vbCrLf
Me.TextBox1.Text += "Line Two" & vbCrLf

That will give you

Line One
Line Two

Feb 13 '06 #7

P: n/a
jvb
Your welcome!

Feb 13 '06 #8

P: n/a
"jvb" <go*****@gmail.com> schrieb:
Me.TextBox1.Text += "Line One" & vbCrLf
Me.TextBox1.Text += "Line Two" & vbCrLf


Mhm... I suggest to use '&=' instead of '+=' to concatenate strings.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Feb 13 '06 #9

P: n/a
One more quick and easy question.
Me.TextBox1.Text += "Line Two" & vbCrLf

How can I make that line BOLD?

Thanks again

"jvb" <go*****@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Your welcome!

Feb 13 '06 #10

P: n/a
jvb
Is there any reason that &= is better than +=? I have always used the
+. Am I going against convention?

Feb 13 '06 #11

P: n/a
You can't in a standard text box.
You'll need to use the rich text box ... different game altogether!
_______________________________
The Grim Reaper

"Jason" <ja***@someone.com> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
One more quick and easy question.
Me.TextBox1.Text += "Line Two" & vbCrLf

How can I make that line BOLD?

Thanks again

"jvb" <go*****@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Your welcome!


Feb 13 '06 #12

P: n/a
I was going to say "you're going against convention!".... but then I checked
my local MSDN and found;

&=
Concatenates a String expression to a String variable or property and
assigns the result to the variable or property.

+=
Adds the value of a numeric expression to the value of a numeric variable or
property and assigns the result to the variable or property. Can also be
used to concatenate a String expression to a String variable or property and
assign the result to the variable or property.

So there you go!
____________________________________
The Grim Reaper

"jvb" <go*****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Is there any reason that &= is better than +=? I have always used the
+. Am I going against convention?

Feb 13 '06 #13

P: n/a
Anyone...

when I run this
Me.TextBox1.Text += "Line One" & vbCrLf
Me.TextBox1.Text += "Line Two" & vbCrLf

I get...

Line One
Line Two

But both lines are selected, is that supposed to be that way? How can I get
rid of the highlighting?

"Jason" <ja***@someone.com> wrote in message
news:OP**************@TK2MSFTNGP11.phx.gbl...
Hello

For a VB novice can anyone help me with the following simple idea.

All I've got on my form is a Textbox, (mulitline = true) and a button.

When I click the button I will have some simple lines of text to be
displayed. How do I have...

Dim addLine As String = "Next Line"
Dim addLine As String = "Another Line"
TextBox1.Text = "Line one"
then the next line display Next Line
and the next display Another Line

What is the newline char? \n

Feb 13 '06 #14

P: n/a
"The Grim Reaper" <gr*********@REMOVEbtopenworld.com> schrieb:
I was going to say "you're going against convention!".... but then I
checked my local MSDN and found;

&=
Concatenates a String expression to a String variable or property and
assigns the result to the variable or property.

+=
Adds the value of a numeric expression to the value of a numeric variable
or property and assigns the result to the variable or property. Can also
be used to concatenate a String expression to a String variable or
property and assign the result to the variable or property.


Mhm... But I remember the documentation for '&' recommends to use '&' for
string concatenation instead of '+'.

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

Feb 13 '06 #15

P: n/a
Me.TextBox1.SelectionStart = 0
Me.TextBox1.SelectionLength = 0

(I haven't had cause to use them much before, so experiment with what you
want to achieve)
___________________________________
The Grim Reaper

"Jason" <ja***@someone.com> wrote in message
news:u$*************@TK2MSFTNGP14.phx.gbl...
Anyone...

when I run this
Me.TextBox1.Text += "Line One" & vbCrLf
Me.TextBox1.Text += "Line Two" & vbCrLf

I get...

Line One
Line Two

But both lines are selected, is that supposed to be that way? How can I
get rid of the highlighting?

"Jason" <ja***@someone.com> wrote in message
news:OP**************@TK2MSFTNGP11.phx.gbl...
Hello

For a VB novice can anyone help me with the following simple idea.

All I've got on my form is a Textbox, (mulitline = true) and a button.

When I click the button I will have some simple lines of text to be
displayed. How do I have...

Dim addLine As String = "Next Line"
Dim addLine As String = "Another Line"
TextBox1.Text = "Line one"
then the next line display Next Line
and the next display Another Line

What is the newline char? \n


Feb 13 '06 #16

P: n/a
Hi,

Try this one with option strict off and be happy

dim a as string = "1"
a += 1

Cor
"The Grim Reaper" <gr*********@REMOVEbtopenworld.com> schreef in bericht
news:ds**********@nwrdmz03.dmz.ncs.ea.ibs-infra.bt.com...
I was going to say "you're going against convention!".... but then I
checked my local MSDN and found;

&=
Concatenates a String expression to a String variable or property and
assigns the result to the variable or property.

+=
Adds the value of a numeric expression to the value of a numeric variable
or property and assigns the result to the variable or property. Can also
be used to concatenate a String expression to a String variable or
property and assign the result to the variable or property.

So there you go!
____________________________________
The Grim Reaper

"jvb" <go*****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Is there any reason that &= is better than +=? I have always used the
+. Am I going against convention?


Feb 13 '06 #17

P: n/a
Thanks

Shouldn't that be in the properties of the Text Box?

Also how do you make a one line of text bold?
Me.TextBox1.Text += "Line One" & vbCrLf
Me.TextBox1.Text += "Line Two" & vbCrLf

"The Grim Reaper" <gr*********@REMOVEbtopenworld.com> wrote in message
news:ds**********@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...
Me.TextBox1.SelectionStart = 0
Me.TextBox1.SelectionLength = 0

(I haven't had cause to use them much before, so experiment with what you
want to achieve)
___________________________________
The Grim Reaper

"Jason" <ja***@someone.com> wrote in message
news:u$*************@TK2MSFTNGP14.phx.gbl...
Anyone...

when I run this
Me.TextBox1.Text += "Line One" & vbCrLf
Me.TextBox1.Text += "Line Two" & vbCrLf

I get...

Line One
Line Two

But both lines are selected, is that supposed to be that way? How can I
get rid of the highlighting?

"Jason" <ja***@someone.com> wrote in message
news:OP**************@TK2MSFTNGP11.phx.gbl...
Hello

For a VB novice can anyone help me with the following simple idea.

All I've got on my form is a Textbox, (mulitline = true) and a button.

When I click the button I will have some simple lines of text to be
displayed. How do I have...

Dim addLine As String = "Next Line"
Dim addLine As String = "Another Line"
TextBox1.Text = "Line one"
then the next line display Next Line
and the next display Another Line

What is the newline char? \n



Feb 13 '06 #18

P: n/a
jvb
To have only one line bold, you have to use a RichTextBox. Select the
text you want and execute this line:

rtb.SelectionFont = New Font(rtb.Font, FontStyle.Bold)

where rtb is the RichTextBox.

Feb 13 '06 #19

P: n/a
If I've got this

Me.RichTextBox1.Text = "In Rich Text Box"
Me.RichTextBox1.Text &= "Line two" & vbCrLf
How do I make the second line BOLD?

"jvb" <go*****@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
To have only one line bold, you have to use a RichTextBox. Select the
text you want and execute this line:

rtb.SelectionFont = New Font(rtb.Font, FontStyle.Bold)

where rtb is the RichTextBox.

Feb 13 '06 #20

P: n/a
CMM
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
Mhm... But I remember the documentation for '&' recommends to use '&' for
string concatenation instead of '+'.


They do. Because it removes uncertainty of the result when Option Strict is
OFF.
When Option Strict is ON there's no reason to choose one over the other. At
that point, it comes down to subjectivity or company standards....

I stopped using & in my move to .NET. But, I miss &.... and standardizing on
+ (for me) has caused problems once in a while.... like when I load up
someone else's code module and it has Option Strict OFF in it and I don't
realize it. :-(

--
-C. Moya
www.cmoya.com
Feb 14 '06 #21

This discussion thread is closed

Replies have been disabled for this discussion.