Probier einfach ma folgendes:
@RodFromGermany: Lass ihn das einfach ma testen
VB.NET-Quellcode
- Option Explicit On
- Public Class frm_GO
- Dim BytesPerLine As Integer
- Dim SerialPortData As String
- Private thread As New Threading.Thread(New Threading.ThreadStart(AddressOf HandleSerialData))
- Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
- 'Me.Invoke(Sub() HandleSerialData(SerialPort1.ReadExisting))
- thread.Start()
- End Sub
- Private Sub frm_EHZMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Me.SerialPort1.Open()
- BytesPerLine = 1
- End Sub
- Private Sub HandleSerialData()
- Dim SerialData As String = SerialPort1.ReadExisting
- Dim str2Append As String = ""
- Dim data As Integer
- Dim ldata(9) As Integer
- Dim i As Integer
- While Me.SerialPort1.BytesToRead >= 0
- data = Me.SerialPort1.ReadByte()
- ldata(9) = data
- For i = 1 To 8
- ldata(i) = ldata(i + 1)
- Next
- 'Me.txt_Stream.AppendText(Microsoft.VisualBasic.Right("0" & Hex(data), 2) & " ")
- str2Append &= Microsoft.VisualBasic.Right("0" & Hex(data), 2) & " "
- BytesPerLine = BytesPerLine + 1
- If BytesPerLine >= 16 Then
- BytesPerLine = 1
- 'Me.txt_Stream.AppendText(vbCrLf)
- str2Append &= vbCrLf
- End If
- If ldata(1) = 27 And ldata(2) = 27 And ldata(3) = 27 And ldata(4) = 27 And ldata(5) = 26 Then
- 'Me.txt_Stream.AppendText("ENDE")
- 'Me.txt_Stream.AppendText(vbCrLf)
- 'Me.txt_Stream.AppendText(vbCrLf)
- 'Me.txt_Stream.AppendText(vbCrLf)
- 'Me.txt_Stream.AppendText(vbCrLf)
- str2Append &= "ENDE" & vbCrLf & vbCrLf & vbCrLf & vbCrLf
- BytesPerLine = 1
- End If
- If ldata(1) = 27 And ldata(2) = 27 And ldata(3) = 27 And ldata(4) = 27 And _
- ldata(5) = 1 And ldata(6) = 1 And ldata(7) = 1 And ldata(8) = 1 Then
- 'Me.txt_Stream.AppendText(vbCrLf)
- 'Me.txt_Stream.AppendText("Start")
- str2Append &= vbCrLf & "Start"
- BytesPerLine = 1
- 'Me.txt_Stream.AppendText(vbCrLf)
- str2Append &= vbCrLf
- End If
- End While
- Me.txt_Stream.Invoke(Sub() Me.txt_Stream.AppendText(str2Append))
- End Sub
- Private Sub frm_EHZMain_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs)
- Me.SerialPort1.Close()
- End Sub
- End Class
@RodFromGermany: Lass ihn das einfach ma testen
In general (across programming languages), a pointer is a number that represents a physical location in memory. A nullpointer is (almost always) one that points to 0, and is widely recognized as "not pointing to anything". Since systems have different amounts of supported memory, it doesn't always take the same number of bytes to hold that number, so we call a "native size integer" one that can hold a pointer on any particular system. - Sam Harwell