barcode scanner component

Ask about the individual Gambas components here.
Post Reply
karthiksg
Posts: 3
Joined: Monday 28th March 2022 2:55pm

barcode scanner component

Post by karthiksg » Tuesday 29th March 2022 7:40am

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

User avatar
cogier
Site Admin
Posts: 875
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: barcode scanner component

Post by cogier » Tuesday 29th March 2022 3:08pm

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.

User avatar
gbWilly
Posts: 41
Joined: Friday 23rd September 2016 11:41am
Location: Netherlands
Contact:

Re: barcode scanner component

Post by gbWilly » 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...
gbWilly
- Dutch translation for Gambas3
- Gambas wiki content contributer


... there is always a Catch if things go wrong!

karthiksg
Posts: 3
Joined: Monday 28th March 2022 2:55pm

Re: barcode scanner component

Post by karthiksg » Thursday 05th May 2022 5:40am

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...

User avatar
cogier
Site Admin
Posts: 875
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: barcode scanner component

Post by cogier » Thursday 05th May 2022 3:24pm

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 13 times

Post Reply