gnappi Posted September 10, 2006 Posted September 10, 2006 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 Quote
Cags Posted September 10, 2006 Posted September 10, 2006 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. Quote Anybody looking for a graduate programmer (Midlands, England)?
gnappi Posted September 11, 2006 Author Posted September 11, 2006 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 Quote
Junkee Posted September 11, 2006 Posted September 11, 2006 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 :) Quote
Cags Posted September 11, 2006 Posted September 11, 2006 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] Quote Anybody looking for a graduate programmer (Midlands, England)?
gnappi Posted September 11, 2006 Author Posted September 11, 2006 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)) Quote
Leaders snarfblam Posted September 11, 2006 Leaders Posted September 11, 2006 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. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.