Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Need Help I would like to ask why my text box can't read the barcode scanned by my program.

$
0
0

I am writing a barcode scanner program i face the issue is when user the 2d barcode scanner Scan the barcode. my textbox can not read the data. can someone help me take a look. Thanks.

below is my program

Private Sub serialPort_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs)
        If TextBox1.Text.Length >= 20 Then
            serialPort.Close()
        Else
            DispString = serialPort.ReadExisting()
        End If
    End Sub

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

        serialPort.PortName = "COM13"
        serialPort.BaudRate = "9600"
        serialPort.Parity = Parity.None
        serialPort.StopBits = StopBits.One
        serialPort.Handshake = Handshake.None
        serialPort.Open()
        serialPort.ReadTimeout = 200

        If serialPort.IsOpen Then
            DispString = ""
            txtCardKeyDeactivate.Text = ""
        End If

    End Sub

Private Sub SendSerialData(ByVal data As String)
        Using COM13 As IO.Ports.SerialPort =
                My.Computer.Ports.OpenSerialPort("COM13")
            COM13.WriteLine(data)
        End Using

    End Sub

    Private Sub ReceiveSerialData(ByVal data As String)

        Dim returnStr As String = ""
        Dim COM13 As IO.Ports.SerialPort = Nothing
        Try
            COM13 = My.Computer.Ports.OpenSerialPort("COM13")
            COM13.ReadTimeout = 10000
            Do
                Dim Incoming As String = COM13.ReadLine()
                If Incoming Is Nothing Then
                    Exit Do
                Else
                    returnStr &= Incoming & vbCrLf
                End If
            Loop
        Catch ex As TimeoutException
            returnStr = "Error: Serial Port read timed out."
        Finally
            If COM13 IsNot Nothing Then COM13.Close()
        End Try
    End Sub
End Class



Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>