Hello everyone , I hope someone can help me with my problem. I’m having a problem with a serial port. I’ve connected a balance to my laptop and I want to get the data from the balance on my computer. So when I weigh something it should be possible to see the weight on my screen.
First off all I’m not very experienced with this matter. So I’m hoping for your help on this.
Here is my code , the settings are correct , I’ve got those from the supplier itself.
My question is, how can I call the mySerialPort_Datareceived method in the Form_Load method and will it work ? thanks for helping me out !
Public Class Form
'SerialPort object creation
WithEvents mySerialPort As New IO.Ports.SerialPort
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'setting the mySerialPort settings
With mySerialPort
.PortName = "COM1"
.BaudRate = 9600
.Parity = IO.Ports.Parity.Even
.DataBits = 7
.StopBits = IO.Ports.StopBits.One
End With
'method to get the get the stream from the balance
Private Sub mySerialPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs)
Console.Write(mySerialPort.ReadExisting)
End Sub
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
AddHandler mySerialPort.DataReceived, AddressOfmySerialPort_DataReceived
End Sub
Kind Regards
Depreytere Cliff
POVLT @ Belgium
First off all I’m not very experienced with this matter. So I’m hoping for your help on this.
Here is my code , the settings are correct , I’ve got those from the supplier itself.
My question is, how can I call the mySerialPort_Datareceived method in the Form_Load method and will it work ? thanks for helping me out !
Public Class Form
'SerialPort object creation
WithEvents mySerialPort As New IO.Ports.SerialPort
Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'setting the mySerialPort settings
With mySerialPort
.PortName = "COM1"
.BaudRate = 9600
.Parity = IO.Ports.Parity.Even
.DataBits = 7
.StopBits = IO.Ports.StopBits.One
End With
'method to get the get the stream from the balance
Private Sub mySerialPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs)
Console.Write(mySerialPort.ReadExisting)
End Sub
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
AddHandler mySerialPort.DataReceived, AddressOfmySerialPort_DataReceived
End Sub
Kind Regards
Depreytere Cliff
POVLT @ Belgium