Page 1 of 1

barcode scanner component

Posted: Tuesday 29th March 2022 7:40am
by karthiksg
how to read usb barcode scanner in gambas.
i tried a sample code from this forum which shows the below error

Code: Select all

unknown identifier: SerialPort (Form1.class:3) error
my lsusb output shows the device details as follows

Code: Select all

Bus 003 Device 020: ID 24ea:0197 Meva Barcode Scanner

Re: barcode scanner component

Posted: Tuesday 29th March 2022 3:08pm
by cogier
Get a USB barcode reader like this one. This reads the barcode and then passes the information back as if it is a keyboard, with an [Enter] at the end. This makes it very easy to program. All you need to do is have a TextBox in focus, scan the barcode and watch for the [Enter] at the end of the read, and you have got the barcode in your program.

Re: barcode scanner component

Posted: Wednesday 30th March 2022 4:56pm
by gbWilly
Hi,

I run into this same problem a while ago.
First of all, forget SerialPort, it is way more simple (as Cogier already stated).
The USB barcode scanner acts as keyboard input.

Make a form with a TextBox (let's call it tbxBarCode) and a Label (let's call it lblScannedBarCode)
Next apply following code on the Form
Form_Open()

  tbxBarCode.SetFocus

End

tbxBarCode_KeyPress()

  If Chr$(13) Then
    lblScannedBarCode.Text = tbxBarCode.Text
  Endif

End
The Label is just to be able to have some code in the KeyPress event to demonstrate that the barcode is scanned.
I have an application that scans this code in a TextBox that is invisible (but keep in mind the TextBox does needs the focus upon scanning) and next, after scanning, starts to give some info on the scanned article (like name, price etc.) retrieved from a database.

I guess you can take it from here, feel free to ask if you get into trouble. ;)

Enjoy...

Re: barcode scanner component

Posted: Thursday 05th May 2022 5:40am
by karthiksg
Hi
[highlight=]I tried this but getting unknown identifier tbxBarCode_KeyPress()[/highlight]

gbWilly wrote:
Wednesday 30th March 2022 4:56pm
Hi,

I run into this same problem a while ago.
First of all, forget SerialPort, it is way more simple (as Cogier already stated).
The USB barcode scanner acts as keyboard input.

Make a form with a TextBox (let's call it tbxBarCode) and a Label (let's call it lblScannedBarCode)
Next apply following code on the Form
Form_Open()

  tbxBarCode.SetFocus

End

tbxBarCode_KeyPress()

  If Chr$(13) Then
    lblScannedBarCode.Text = tbxBarCode.Text
  Endif

End
The Label is just to be able to have some code in the KeyPress event to demonstrate that the barcode is scanned.
I have an application that scans this code in a TextBox that is invisible (but keep in mind the TextBox does needs the focus upon scanning) and next, after scanning, starts to give some info on the scanned article (like name, price etc.) retrieved from a database.

I guess you can take it from here, feel free to ask if you get into trouble. ;)

Enjoy...

Re: barcode scanner component

Posted: Thursday 05th May 2022 3:24pm
by cogier
I have altered gbWilly's code a little. This little program works well with my USB reader.
SimpleBarcode-0.0.1.tar.gz
(11.86 KiB) Downloaded 12 times