Home All Groups Group Topic Archive Search About
Author
13 Feb 2006 7:03 PM
Jason
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

Author
13 Feb 2006 7:13 PM
jvb
vbCrLf
Author
13 Feb 2006 7:22 PM
Jason
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?

Show quoteHide quote
"jvb" <gome***@gmail.com> wrote in message
news:1139858036.243160.312900@o13g2000cwo.googlegroups.com...
> vbCrLf
>
Author
13 Feb 2006 7:28 PM
jvb
Try this...

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

That will give you

Line One
Line Two
Author
13 Feb 2006 7:46 PM
Jason
Thanks, that works.
Show quoteHide quote
"jvb" <gome***@gmail.com> wrote in message
news:1139858889.407567.133070@g43g2000cwa.googlegroups.com...
> Try this...
>
> Me.TextBox1.Text += "Line One" & vbCrLf
> Me.TextBox1.Text += "Line Two" & vbCrLf
>
> That will give you
>
> Line One
> Line Two
>
Author
13 Feb 2006 7:50 PM
jvb
Your welcome!
Author
13 Feb 2006 8:02 PM
Jason
One more quick and easy question.
Me.TextBox1.Text += "Line Two" & vbCrLf

How can I make that line BOLD?

Thanks again

Show quoteHide quote
"jvb" <gome***@gmail.com> wrote in message
news:1139860258.576021.153130@o13g2000cwo.googlegroups.com...
> Your welcome!
>
Author
13 Feb 2006 8:11 PM
The Grim Reaper
You can't in a standard text box.
You'll need to use the rich text box ... different game altogether!
_______________________________
The Grim Reaper

Show quoteHide quote
"Jason" <ja***@someone.com> wrote in message
news:%239PsohNMGHA.532@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" <gome***@gmail.com> wrote in message
> news:1139860258.576021.153130@o13g2000cwo.googlegroups.com...
>> Your welcome!
>>
>
>
Author
13 Feb 2006 7:56 PM
Herfried K. Wagner [MVP]
"jvb" <gome***@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/>
Author
13 Feb 2006 8:05 PM
jvb
Is there any reason that &= is better than +=? I have always used the
+. Am I going against convention?
Author
13 Feb 2006 8:15 PM
The Grim Reaper
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

Show quoteHide quote
"jvb" <gome***@gmail.com> wrote in message
news:1139861138.148357.178990@f14g2000cwb.googlegroups.com...
> Is there any reason that &= is better than +=? I have always used the
> +. Am I going against convention?
>
Author
13 Feb 2006 8:19 PM
Herfried K. Wagner [MVP]
"The Grim Reaper" <grim_rea***@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/>
Author
14 Feb 2006 5:18 AM
CMM
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@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
Author
13 Feb 2006 8:28 PM
Cor Ligthert [MVP]
Hi,

Try this one with option strict off and be happy

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

Cor


Show quoteHide quote
"The Grim Reaper" <grim_rea***@REMOVEbtopenworld.com> schreef in bericht
news:dsqpcf$nk9$1@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" <gome***@gmail.com> wrote in message
> news:1139861138.148357.178990@f14g2000cwb.googlegroups.com...
>> Is there any reason that &= is better than +=? I have always used the
>> +. Am I going against convention?
>>
>
>
Author
13 Feb 2006 7:30 PM
Herfried K. Wagner [MVP]
Show quote Hide quote
"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/>
Author
13 Feb 2006 7:37 PM
Jim Wooley
> What is the newline char?  \n

ControlChars.CrLf
Author
13 Feb 2006 8:14 PM
Jason
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?

Show quoteHide quote
"Jason" <ja***@someone.com> wrote in message
news:OPd89ANMGHA.3144@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
>
>
Author
13 Feb 2006 8:19 PM
The Grim Reaper
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

Show quoteHide quote
"Jason" <ja***@someone.com> wrote in message
news:u$7yRoNMGHA.648@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:OPd89ANMGHA.3144@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
>>
>>
>
>
Author
13 Feb 2006 8:29 PM
Jason
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

Show quoteHide quote
"The Grim Reaper" <grim_rea***@REMOVEbtopenworld.com> wrote in message
news:dsqpkn$g10$1@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$7yRoNMGHA.648@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:OPd89ANMGHA.3144@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
>>>
>>>
>>
>>
>
>
Author
13 Feb 2006 9:02 PM
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.
Author
13 Feb 2006 9:33 PM
Jason
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?

Show quoteHide quote
"jvb" <gome***@gmail.com> wrote in message
news:1139864547.410442.110080@z14g2000cwz.googlegroups.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.
>