Results 1 to 3 of 3

Thread: Serial Port: Read data and update TextBox content

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2024
    Posts
    2

    Serial Port: Read data and update TextBox content

    Hi there,

    I need some help with serial port data readings from a scale connected to my pc.

    I found a very simple way to read data from the serial port and show the results each time the serial port receives data:

    First, I open the serial port with a click on a button:

    Code:
    Private Sub Button1_Click_2(sender As Object, e As EventArgs) Handles Button1.Click
            SerialPort1.Open()
    End Sub
    Then, each time the scale sends data, I can display it it in the console window:

    Code:
    Private Sub SerialPort1_DataReceived(sender As Object, e As IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
            Console.WriteLine(SerialPort1.ReadLine())
    End Sub

    I would like to simply display the data in a textbox, but get errors

    Code:
      Private Sub SerialPort1_DataReceived(sender As Object, e As IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
          Dim returnStr As String = ""
          returnStr = SerialPort1.ReadLine()
          TextBoxWaage_Read.Text = returnStr
          Console.WriteLine(returnStr)
      End Sub
    Has anyone a SIMPLE solution for this?

    Thank you,

    Thomas
    Last edited by jmcilhinney; Apr 27th, 2024 at 03:01 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width