Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm trying to make a multiline scrolling textbox but with TextBox (Multiline=True)

or RichTextBox (Multiline=True) the last string overwrites the text. What am I missing?

 

 

Thanks,

 

Gary

Posted
What do you mean the last string overwrites the text. You will have to provide some code, as I'm not sure what your problem is.
Anybody looking for a graduate programmer (Midlands, England)?
Posted
What do you mean the last string overwrites the text. You will have to provide some code' date=' as I'm not sure what your problem is.[/quote']

 

Print one line CR/LF

Print one line CR/LF

 

Something like:

 

RichTextBox1.Text = "test:"

RichTextBox1.Text = "test2"

or

TextBox2.Text = "Test1 " & vbCrLf & vbCrLf

TextBox2.Text = "test2"

 

Right now EVERYTHING prints on one line, meaning that the test2 message overwrites test1.

 

Regards,

 

Gary

Posted

HI,

 

try using the += operator to append text, for example:

RichTextBox1.Text = "This is "

RichTextBox1.Text += "some text."

The RTB should now contain "This is some text.", rather than "some text." which you would have got if you hadn't used +=.

 

Hope that helps, sorry if I misunderstand the question :)

Posted

Of course it does, I thought that might be what your doing. First you are assigning Test1 and a couple of char return line feeds to the Text property. Then you assign the Text property as equal to test2. Using the uquals operator in this manner will assign the object on the left equal to the object on the right, not add it.

 

If you wish to append more text you should use one of these methods.

RichTextBox1.Text += "test2"
' or alternatively
RichTextBox1.Text = RichTextBox1.Text & "test2"

[edit]Beaten to the punch....[/edit]

Anybody looking for a graduate programmer (Midlands, England)?
Posted
Of course it does, I thought that might be what your doing. First you are assigning Test1 and a couple of char return line feeds to the Text property. Then you assign the Text property as equal to test2. Using the uquals operator in this manner will assign the object on the left equal to the object on the right, not add it.

 

If you wish to append more text you should use one of these methods.

RichTextBox1.Text += "test2"
' or alternatively
RichTextBox1.Text = RichTextBox1.Text & "test2"

[edit]Beaten to the punch....[/edit]

 

Thanks for the replies, but I finally came up with a solution using the following syntax.

 

TextBox2.AppendText(vbCrLf + ("linetest1 "))

TextBox2.AppendText(vbCrLf + ("linetest2 ") + (speaker_status))

  • Leaders
Posted

Just so you know, you really don't need all those parentheses.

TextBox2.AppendText(vbCrLf + "linetest1 ")
TextBox2.AppendText(vbCrLf + "linetest2 " + speaker_status)

Would be exactly the same as:

TextBox2.AppendText(vbCrLf + ("linetest1 "))
TextBox2.AppendText(vbCrLf + ("linetest2 ") + (speaker_status))

You might want to consider using the & and &= operators for joining strings because it makes it clear that you want to concatenate, not add.

Dim Result As Object
Dim Value1 As Integer = 10
Dim Value2 As Integer = "11"

Result = Value1 + Value2 ' 10 + "11" = 21? Or "1011"?
Result = Value1 & Value2 ' 10 & "11" = "1011" because & can't add.

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...