I'm working on a project in vb.net 2010 that has 3 RichTextBoxes. Two of the RichTextBoxes can be loaded with text from text files. How do I take the multiple lines of text from each RichTextBox and combine them into the 3rd RichTextBox.
For example, if 2 of the RichTextBoxes contain the following lines of text:
I want the 3rd RichTextBox to show following result:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim FirstBox() As String = RichTextBox1.Lines
Dim SecondBox() As String = RichTextBox2.Lines
If FirstBox.Count <> SecondBox.Count Then Exit Sub
For i = 0 To UBound(FirstBox)
RichTextBox3.Text &= FirstBox(i) & " " & SecondBox(i) & vbCrLf
If this solves your problem, mark it as solved. If not say why it didn't solve your problem.
Thank you very much. The code worked in combining the text lines, but the results were mixed in that several of the text lines have gaps (trailing spaces & tab spaces) between the text. I tried using the Trim Method, but it didn't seem to work.