Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27052

VS 2010 String manipulation

$
0
0
Hi, I have som data comming from the serial port. The data needs to be manipulated in several steps.

1. The response 80 means that 2 bytes will follow, High and Low byte.
I have a RichTextbox which is holding the data. (probably faster with a StringBuilder, but now I need to see what happends).
I'll try to add the high and low byte, and then overwrite the line 80. And then delete the high and low byte line.

I could need some help this is the code:
Code:

Dim HighByte As String
        Dim LowByte As String
        Dim Sum As String

        For i As Integer = 0 To TxtBytes.Lines.Length - 1
            If TxtBytes.Lines(i) = "80" Then
                HighByte = (TxtBytes.Lines(i + 1))
                LowByte = (TxtBytes.Lines(i + 2))
                Sum = (HighByte & LowByte)
                TxtBytes.Text = Replace(TxtBytes.Text, TxtBytes.Lines(i + 1), String.Empty, , 1)
                TxtBytes.Text = Replace(TxtBytes.Text, TxtBytes.Lines(i + 2), String.Empty, , 1)
                TxtBytes.Text = Replace(TxtBytes.Text, TxtBytes.Lines(i), Sum, , 1)
            End If
        Next
        Me.TxtBytes.Lines = Me.TxtBytes.Text.Split(New Char() {ControlChars.Lf}, _
                                                          StringSplitOptions.RemoveEmptyEntries)

And this is the output:

Name:  Exp.png
Views: 10
Size:  11.9 KB
Attached Images
 

Viewing all articles
Browse latest Browse all 27052

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>