Results 1 to 9 of 9

Thread: Capture Barcode Text

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    187

    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.

  2. #2
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Capture Barcode Text

    Quote 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??

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    187

    Re: Capture Barcode Text

    Quote 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?


  4. #4
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Capture Barcode Text

    Quote 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??

  5. #5
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

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

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Feb 2007
    Posts
    187

    Re: Capture Barcode Text

    Quote 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?

  7. #7
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Capture Barcode Text

    Quote 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??

  8. #8
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: Capture Barcode Text

    Here's a thought... When you plug the scanner into the port does it show up as an attached device in the Device Manager? If it does then there's probably an API that may capture that event which could be used to put your app on top with the focus.
    <--- 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??

  9. #9
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,526

    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
  •  



Click Here to Expand Forum to Full Width