Hi forum
I am not sure how to use data received events from this code I given.. Can you help me please.I dont know where to put the data received events.
Imports System.IO
Imports System.IO.Ports
Imports System.Threading
Imports System.Data
Imports System.Text
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
SerialPort1.Close()
SerialPort1.PortName = "com4" 'change com port to match your Arduino port
SerialPort1.BaudRate = 9600
SerialPort1.DataBits = 8
SerialPort1.Parity = Parity.None
SerialPort1.StopBits = StopBits.One
SerialPort1.Handshake = Handshake.None
SerialPort1.Encoding = System.Text.Encoding.Default 'very important!
End Sub
Private Sub Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Start.Click
Dim SP As String
Dim FB As Integer
Dim A As Integer
SP = TextBox1.Text
FB = CInt(Label2.Text)
A = SP - FB
Label3.Text = A
SerialPort1.Open()
SerialPort1.Write(A)
End Sub
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs)
Dim s As String
Try
s = SerialPort1.ReadExisting()
Label2.Text = s
Catch ex As Exception
End Try
End Sub
End Class