Hi i am trying to append text from a continuous receiving data The length of the text i am getting is like 1, 2, 5, 4, 1 etc.. i need first 5 byte of data i am trying to add it in another variable called K if length of K reaches the length of 5, I will move it to Variable J and will clear K
Dim j = ""
Dim l = ""
Dim k As String
Private Sub ReceivedText(ByVal [text] As String) 'input from ReadExisting
Dim payload As Byte()
Dim station = TextBox1.Text
Dim number As String = Regex.Replace([text], "[^0-9]", "")
If number.Length > 0 Then
K = K + number
If K.Length = 5 Then
j = K
K = ""
ElseIf k.Length > 5 Then
j = K.Substring(0, 5)
If j.Length = 5 Then
l = K.Remove(5)
K = ""
K = l
End If
End If
If Me.RichTextBox1.InvokeRequired Then
Dim x As New SetTextCallback(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
Else
Me.RichTextBox1.Text = K
End If
End If
if the variable K length is greater than 5, I will add 5 in the first variable to "J" and balance to another variable called l and append that to K, so i will get the first variable to stay constantly to the length of 5 but using the above code i cant get the desired result, any suggestions will be really appreciated
Dim k As Stringwill initialize new variable with value equalsNothing.