Roger G. (Gast
Ziehe 3 Labels ,Timer und Com auf die Form
Der Timer schreibt nur die Daten in das Label(textbox)
Imports System
Imports System.Text ' <=== !
Public Class Form1
Dim daten As Byte
Dim t_zahl, zahl As Integer
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
t_zahl = t_zahl + 1
If t_zahl = 100 Then
t_zahl = 0
End If
Label3.Text = "Datenempfang Aktiv " & zahl
Label1.Text = "Datenwert"
Label2.Text = daten
End Sub
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e
As System.IO.Ports.SerialDataReceivedEventArgs) Handles
SerialPort1.DataReceived
zahl = zahl + 1
If zahl = 100 Then
zahl = 0
End If
daten = SerialPort1.ReadByte()
SerialPort1.DiscardInBuffer()
' Label2.Text = daten 'fehler
End Sub
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
SerialPort1.Close()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
SerialPort1.Open()
End Sub
End Class
Vielleicht hilft es ?
Gruß