Hello guys
I want to ask how to split lines in Richtextbox.
I have a program that work as a client. The server sent client data
ex:
Ship Speed : 40 KM/H
Direction : North - West
etc
the data is sent to client and displayed on Richtexbox at Client Form.
What i want to do right now is to split lines to textboxes
ex
Text box 1 show 40 KM/H
Text box 2 show North - West
etc
Can anyone help me? (sorry for bad grammar)
Hope my question is not confusing.
Thank you
Edit:
This is my code i tried:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim tbarry() As String = RichTextBox1.Lines.Clone
TextBox1.Text = tbarry(0)
TextBox2.Text = tbarry(1)
TextBox3.Text = tbarry(2)
it works when i try it in new project. But it crash when i tried to implement it to my main program
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Listener.Pending = True Then
Message = ""
Client = Listener.AcceptTcpClient()
Dim Reader As New StreamReader(Client.GetStream())
Dim tbarry() As String = RichTextBox1.Lines.Clone
While Reader.Peek > -1
Message = Message + Convert.ToChar(Reader.Read()).ToString
End While
RichTextBox1.ForeColor = Color.Black
RichTextBox1.Text += Message + vbCrLf
RichTextBox1.Text = RichTextBox1.Text.Replace(RichTextBox1.Text, Message + vbCrLf)
RichTextBox2.ForeColor = Color.Black
RichTextBox2.Text += Message + vbCrLf
RichTextBox2.Text = RichTextBox2.Text.Replace(RichTextBox2.Text, Message + vbCrLf)
TextBox1.Text = tbarry(0)
TextBox2.Text = tbarry(1)
TextBox3.Text = tbarry(2)
End If
End Sub
it said "Index was outside the bounds of the array"