1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
Public Class Form1
Delegate Sub SetTextCallback(ByVal Recu As String)
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles mySerialPort.DataReceived
System.Threading.Thread.Sleep(100) 'une pause de 100ms
SetText(mySerialPort.ReadExisting())
End Sub
Private Sub SetText(ByVal Recu As String)
If Me.textbox1.InvokeRequired Then
Dim d As New SetTextCallback(AddressOf SetText)
Me.Invoke(d, New Object() {Recu})
Else
me.textbox1.text = Recu
End If
End Sub
end class |