barcode scanner component

Post

Posted
Rating:
#1 (In Topic #833)
Trainee
how to read usb barcode scanner in gambas.
i tried a sample code from this forum which shows the below error

Code

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

Code

Bus 003 Device 020: ID 24ea:0197 Meva Barcode Scanner
Online now: No Back to the top

Post

Posted
Rating:
#2
Avatar
Guru
cogier is in the usergroup ‘Guru’
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.
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
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

Code (gambas)

  1. Form_Open()
  2.  
  3.   tbxBarCode.SetFocus
  4.  
  5.  
  6. tbxBarCode_KeyPress()
  7.  
  8.   If Chr$(13) Then
  9.     lblScannedBarCode.Text = tbxBarCode.Text
  10.  

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
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#4
Trainee
Hi
I tried this but getting unknown identifier tbxBarCode_KeyPress()


gbWilly said

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

Code (gambas)

  1. Form_Open()
  2.  
  3.   tbxBarCode.SetFocus
  4.  
  5.  
  6. tbxBarCode_KeyPress()
  7.  
  8.   If Chr$(13) Then
  9.     lblScannedBarCode.Text = tbxBarCode.Text
  10.  

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…
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Guru
cogier is in the usergroup ‘Guru’
I have altered gbWilly's code a little. This little program works well with my USB reader.

Attachment
Online now: No Back to the top
1 guest and 0 members have just viewed this.