|
-
Nov 19th, 2008, 10:45 PM
#1
Thread Starter
Addicted Member
Capture Barcode Text
Hi,
I would like to ask something about barcode.
I have a USB barcode scanner, scanned text will show at my VB app text box.
Beside showing on the text box, any other way to capture the scanned text?
Thanks.
-
Nov 19th, 2008, 11:03 PM
#2
Re: Capture Barcode Text
 Originally Posted by ashly
Hi,
I would like to ask something about barcode.
I have a USB barcode scanner, scanned text will show at my VB app text box.
Beside showing on the text box, any other way to capture the scanned text?
Thanks.
Any Text that you can import into your VB app can be saved to a txt file, Excel Book, Data Base etc....
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Nov 19th, 2008, 11:18 PM
#3
Thread Starter
Addicted Member
Re: Capture Barcode Text
 Originally Posted by CDRIVE
Any Text that you can import into your VB app can be saved to a txt file, Excel Book, Data Base etc....
hmm... currently my text box always need to got focus then only I can get the scanned data.
beside doing this, is there any other way to get the scanned data if the text box is lost focus?
-
Nov 19th, 2008, 11:34 PM
#4
Re: Capture Barcode Text
 Originally Posted by ashly
hmm... currently my text box always need to got focus then only I can get the scanned data.
beside doing this, is there any other way to get the scanned data if the text box is lost focus?

Ah, so the USB readers follow the same rules as the PS2 Keyboard readers. They also just send the text to any open text editor that has the focus. Does this mean that you've not written any code for it?
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Nov 19th, 2008, 11:43 PM
#5
Re: Capture Barcode Text
I wrote this over the last year for someone using a keyboard input barcode scanner. It should work for your USB model though.
Code:
' http://news.devx.com/showthread.php?p=500739#post500739
' The BarCode Reader code only accepts input to Text3 while Check1 is checked.
' While Check1 is checked Text1 & Text2 are disabled and focus is put back on
' Text3. This code can be tested with the keyboard.
Option Explicit
Private Sub Form_Load()
Show
Text3.SetFocus
Timer1.Enabled = False
Check1.Caption = "Input Barcode"
End Sub
Private Sub Check1_Click()
Timer1.Enabled = True
Timer1.Interval = 2500
If Check1.Value = 1 Then
Text1.Enabled = False 'Disable Text1&2 while
Text2.Enabled = False 'Barcode reader is reading.
Text3.Text = "Bar code input restricted to this window"
Print "Press any key to simulate Barcode input."
Else
Text1.Enabled = True
Text2.Enabled = True
Cls
End If
End Sub
Private Sub Text3_Change()
If Check1.Value = 0 Then Text3.Text = "" 'Don't accept any input.
End Sub
Private Sub Timer1_Timer()
If Check1.Value = 1 Then Text3.SetFocus
Text3.Text = ""
Timer1.Enabled = False
End Sub
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Nov 19th, 2008, 11:46 PM
#6
Thread Starter
Addicted Member
Re: Capture Barcode Text
 Originally Posted by CDRIVE
I wrote this over the last year for someone using a keyboard input barcode scanner. It should work for your USB model though.
Code:
' http://news.devx.com/showthread.php?p=500739#post500739
' The BarCode Reader code only accepts input to Text3 while Check1 is checked.
' While Check1 is checked Text1 & Text2 are disabled and focus is put back on
' Text3. This code can be tested with the keyboard.
Option Explicit
Private Sub Form_Load()
Show
Text3.SetFocus
Timer1.Enabled = False
Check1.Caption = "Input Barcode"
End Sub
Private Sub Check1_Click()
Timer1.Enabled = True
Timer1.Interval = 2500
If Check1.Value = 1 Then
Text1.Enabled = False 'Disable Text1&2 while
Text2.Enabled = False 'Barcode reader is reading.
Text3.Text = "Bar code input restricted to this window"
Print "Press any key to simulate Barcode input."
Else
Text1.Enabled = True
Text2.Enabled = True
Cls
End If
End Sub
Private Sub Text3_Change()
If Check1.Value = 0 Then Text3.Text = "" 'Don't accept any input.
End Sub
Private Sub Timer1_Timer()
If Check1.Value = 1 Then Text3.SetFocus
Text3.Text = ""
Timer1.Enabled = False
End Sub
does this means that if the vb program gets input from barcode scanner, then the program form must always on top & got focus?
-
Nov 20th, 2008, 12:17 AM
#7
Re: Capture Barcode Text
 Originally Posted by ashly
does this means that if the vb program gets input from barcode scanner, then the program form must always on top & got focus? 
To the best of my knowledge... yes! That's a standard Windows convention. However, you may be able to build an app that activates (gets the focus) when it sees certain data on the port. You'll need a USB savvy programmer to help you with that though.
<--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
If topic has been resolved, please pull down the Thread Tools & mark it Resolved.
Is VB consuming your life, and is that a bad thing?? 
-
Nov 20th, 2008, 12:27 AM
#8
-
Nov 20th, 2008, 01:08 PM
#9
Re: Capture Barcode Text
Unless you prevent your App from losing focus when the bar code scanner is attached, which would require the user to disconnect it to use the PC for anything else, another program could still be given the focus.
An alternative that might work, if the bar code scanner you are using has the capability, is to assign a prefix code that the scanner sends before each data scan. Most recent scanners have this capability - check the manual for yours. You could program your App to watch for this prefix code, and make sure it has the focus and moves the cursor to the appropriate field. Your App would probably have to make sure to capture all input to look for the prefix code, and pass on data not intended for it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|