I am working on barcode reading software. Runs ok, but reads at the most 8 characters at a time. How can I get it to read the entire barcode rather than in pieces?
Here is a snippet of my code
Imports System.Data.SqlClient
Imports System.IO.Ports
Public Class Form1
Private BarCodeEnabled As Boolean
'Private WithEvents ComPort As IO.Ports.SerialPort = My.Computer.Ports.OpenSerialPort(Settings1.Default .ComPort)
Dim WithEvents ComPort As New IO.Ports.SerialPort
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If ComPort.IsOpen Then
ComPort.Close()
End If
Try
With ComPort
.PortName = "Com3"
.BaudRate = 300
.Parity = IO.Ports.Parity.None
.DataBits = 8
.StopBits = IO.Ports.StopBits.One
'.ReadBufferSize = 20
''.ReceivedBytesThreshold = 50
'.StopBits = 1
'.ReadTimeout = 100
'.Handshake = IO.Ports.Handshake.None
'.RtsEnable = True
'.DtrEnable = True
'.Encoding = System.Text.Encoding.ASCII
' .Encoding = System.Text.Encoding.Unicode
End With
ComPort.Open()
End Sub
Private Sub DataReceived( _
ByVal sender As Object, _
ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _
Handles ComPort.DataReceived
txtDataReceived.Invoke(New _
myDelegate(AddressOf updateTextBox), _
New Object() {})
End Sub
Public Delegate Sub myDelegate()
Public Sub updateTextBox()
With txtDataReceived
MsgBox(ComPort.ReadExisting)
End With
End Sub
I also tried ComPort.Readline, but got an I/O thread error.
Your help would be greatly appreciated.