Hello,
I am trying to listen to the COM3 port and display the output in the TextBox.
If I understood correctly I will have to implement this by using eventhandlers, delegates.
I tried following these articles:
http://www.informit.com/articles/article.aspx?p=23020
http://www.xtremevbtalk.com/showthread.php?t=159976
And this is the code I came up with...
Unfortunately it doesn't display anything. App just starts display "True" and no data is being displayed.
I am monitoring Arduino platform which I know is sending data constantly.
I am really new into the vb.net. I am sure there are some horrible mistakes with this code but I am kind of stuck for the past 2 days on this one. Maybe someone could point me in the right direction. Thanks!Code:Imports System.IO.Ports Imports System.Text Public Class ArduinoSerial Public Event ReceivedSerialData(ByVal data As String) WithEvents Serial As SerialPort Dim data As String Private Sub ArduinoSerial_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Serial = My.Computer.Ports.OpenSerialPort("COM3", 9600) TextBox.AppendText(Serial.IsOpen & vbCrLf) End Sub Private Sub Serial_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles Serial.DataReceived RaiseEvent ReceivedSerialData(data) End Sub Public Sub DisplaySerialData(ByVal data) Handles Me.ReceivedSerialData TextBox.AppendText(data & vbCrLf) End Sub End Class![]()




Reply With Quote