Перейти к основному контенту
Центр разработки для Windows

 none
May i ask how can i solve this error message (System.Windows.Forms.TextBox, Text:) i have try many way to solve but still not success to solve the problem. RRS feed

  • Вопрос

  • I face the issue is after i scan my barcoede i will get this error message on my textbox1 can someone pls tell me how can i solve.

    is i missing something.

    Public Class Form1
        Private dataIn As String

     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            SerialPort.PortName = "COM1"
            SerialPort.BaudRate = CInt("9600")
            SerialPort.Parity = Parity.None
            SerialPort.StopBits = StopBits.One
            SerialPort.Handshake = Handshake.None
            SerialPort.Open()
            SerialPort.ReadTimeout = 200

            If SerialPort.IsOpen Then
                TextBox1.Text = ""
            End If
        End Sub

     Private Sub SerialPort_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort.DataReceived
            dataIn = SerialPort.ReadExisting
            TextBox1.Text += SerialPort.ReadExisting().ToString()
            SetText(TextBox1.ToString())

        End Sub
        Delegate Sub SetTextCallback(ByVal text As String)

        Private Sub SetText(ByVal text As String)
            If Me.TextBox1.InvokeRequired Then
                Dim d As SetTextCallback = New SetTextCallback(AddressOf SetText)
                Me.Invoke(d, New Object() {text})
            Else
                Me.TextBox1.Text = text.ToString


            End If
        End Sub


     

    • Изменено christing 18 ноября 2019 г. 3:29
    18 ноября 2019 г. 1:22

Ответы

  • Maybe try this too:

    Private Sub SerialPort_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort.DataReceived

       dataIn = SerialPort.ReadExisting

       SetText( dataIn)

    End Sub

     

    • Помечено в качестве ответа christing 18 ноября 2019 г. 7:47
    18 ноября 2019 г. 6:20

Все ответы