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 2019年11月18日 上午 03:29
    2019年11月18日 上午 01: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 2019年11月18日 上午 07:47
    2019年11月18日 上午 06:20

所有回覆

  • Hi christing,

    >> SetText(TextBox1.ToString())

    The parameter of method SetText should be TextBox1.Text, and the TextBox1.ToString() shows the class name which cause the issue you described.

    So you shoulde modify SetText(TextBox1.ToString()) to SetText(TextBox1.Text).

    Best Regards,

    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2019年11月18日 上午 05:20
  • @Daniel_Zhang-MSFT

    Thank you replay message for me. 

    After i change  SetText(TextBox1.ToString()) to SetText(TextBox1.Text). after i scan barcode i no success get the barcode information to my textbox. is i doing wrong or missing something. can you teaching me thanks. 

     
    2019年11月18日 上午 05:39
  • 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 2019年11月18日 上午 07:47
    2019年11月18日 上午 06:20
  • @Viorel

    Thanks for your message i success get the data already. :)

    really thanks a lot

    2019年11月18日 上午 07:47
  • For problem services/utilities go to control-panel/administrator tools/event viewer/system/expand the tree/locate the time-date of the event/warning/properties/see what the OS says.For detailed help,go to Microsoft/TechNet errors.

    https://technet.microsoft.com/en-us/ms772425.aspx

    use the search settings & enter properties....

    2019年11月18日 下午 05:20