Previous in Forum: Sims House Party   Next in Forum: EMR Software
Close
Close
Close
6 comments
Rate Comments: Nested
Active Contributor

Join Date: Jan 2008
Location: India
Posts: 10

USB Barcode Scanner

02/23/2009 7:22 AM

I have interfaced a USB barcode scanner to a computer running VB6 software with Windows Xp as the OS. Normally people use Barcode scanner with serial port.
The USB barocde scanner is a Plug and Play device so wherever the cursor is placed it dumps the decoded value at the place of the cursor at a high speed.
I have written the code as:
Private Sub txtbarcode_Change()
Dim BARCODE As String

BARCODE = txtbarcode.Text
......(further processing of values)
End Sub

When I place a breakpoint on the first line and run the code, the first character gets dumped on the screen and the rest of the charcaters at the beginning of the first line.
What can be done to avoid this, If I use txtbarcode_Getfocus()..then the value stays on the display but no further processing is done.
We use MsComm while using the serial port..so is such kind of coding required for USB also..please help me out.

Register to Reply
Pathfinder Tags: USB barcode scanner vb 6 vb6
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Participant

Join Date: Jan 2009
Posts: 3
#1

Re: USB Barcode Scanner

02/23/2009 12:35 PM

The USB barcode scanner acts like a keyboard. The characters come in one at a time, but fast. Put the code into the _KeyPress or _KeyDown event.

Try this:

'Put focus on txtBarcode ...
Private Sub txtBarcode_KeyPress(KeyAscii As Integer)
If KeyAscii = &H0D then
....Process bar code here
End If
End Sub

Hope this helps,
Phil

Register to Reply
Active Contributor

Join Date: Jan 2008
Location: India
Posts: 10
#3
In reply to #1

Re: USB Barcode Scanner

02/24/2009 12:19 AM

Thanks a lot for ur input.

I tried to put in the code you had suggested but no progress..the first character of the barcode comes on the screen ,then a message pops up saying the action will reset your project givinig options of Ok and cancel and then the rest of the barcode value gets dumped on the screen.

Register to Reply
Active Contributor

Join Date: Jan 2008
Location: India
Posts: 10
#4
In reply to #1

Re: USB Barcode Scanner

02/26/2009 12:06 AM

For a stop gap arrangement I have modified the code like:

I have declared the BARCODE as global variable

Private Sub txtbarcode_Change()

BARCODE = txtbarcode.Text

End Sub

I have then used a function to further process the barcode. A cmd button is used to actuate that function. Hence the operations for the operator increases.

Register to Reply
Guru
Popular Science - Weaponology - New Member Netherlands - Member - New Member Fans of Old Computers - Commodore 64 - New Member

Join Date: Sep 2007
Location: Japan
Posts: 2703
Good Answers: 38
#5
In reply to #4

Re: USB Barcode Scanner

02/26/2009 1:13 AM

You could try to put the code in an array if every time the event gets launched

__________________
From the Movie "The Big Lebowski" Don't pee on the carpet man!
Register to Reply
Guru
Popular Science - Weaponology - New Member Netherlands - Member - New Member Fans of Old Computers - Commodore 64 - New Member

Join Date: Sep 2007
Location: Japan
Posts: 2703
Good Answers: 38
#2

Re: USB Barcode Scanner

02/23/2009 11:06 PM

I am not exactly sure what you mean

Is it that only the first character changes?

then it should be

BARCODE = BARCODE & txtbarcode.Text

i hope this is helpfull

__________________
From the Movie "The Big Lebowski" Don't pee on the carpet man!
Register to Reply
Active Contributor

Join Date: Jan 2008
Location: India
Posts: 10
#6

Re: USB Barcode Scanner

02/28/2009 12:17 AM

I have put a timer to check whether the any string comes in that particular field. Therefore whenever the string comes a function gets activated and decode of the barcode happens.

So finally the problem is solved. Thanks to all those who contributed.

Register to Reply
Register to Reply 6 comments
Copy to Clipboard

Users who posted comments:

Epke (2); Jais (3); pliberatore (1)

Previous in Forum: Sims House Party   Next in Forum: EMR Software
You might be interested in: USB Connectors, USB Products, Bar Code Decoders

Advertisement