HI;
You want to pull the data from the serial Port?
So, you should use the serial port receive event, like this one;
The total code, should be something like this;Code:Private Sub DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived Dim recepcao As String ' do what you want you the recepcao variable
First you need to add the serilport class to your project.
Then, at Form Load, you need to configure and open your SerialPort;Code:Public Class Form1 Dim WithEvents SerialPort1 As New IO.Ports.SerialPort
This handles the recetion from the buffer of the com port, and then i have a If statment to do the actions that need to be perfomed acording with the received data.Code:Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load SerialPort1.PortName = "COM1" SerialPort1.Parity = IO.Ports.Parity.None SerialPort1.BaudRate = 9600 SerialPort1.DataBits = 8 SerialPort1.StopBits = 1 SerialPort1.Open() End Sub
After you have this working, you sould put some "Try ...Catch" code, to handle the erros!Code:Private Sub DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived Dim recepcao As String recepcao = SerialPort1.ReadExisting If recepcao = "%TE" Then GetCursorPos(rect) SetCursorPos(rect.X - 1, rect.Y) End IF
Hope it can help you!




Bookmarks