none
Barcode reader implementation RRS feed

  • Question

  • Does anybody know how to implement Barcode reader to VB 2005 programming?
    I need the basic concept, please help to guide : )

    Wednesday, July 2, 2008 2:10 AM

Answers

  •  This is enough code to test your barcode scanner.
    Public Class Form1  
        Dim mScannedData As String 
     
        Private Sub ComboBox1_KeyDown(ByVal sender As ObjectByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyDown  
            Dim lResult As Boolean 
     
            Select Case e.KeyCode  
                Case 13  
     
     
                    ValidateMyData()  
     
                    lResult = DetermineExisting()  
     
                    Select Case lResult  
                        Case True 
                            MsgBox("This Item Has already been scanned!")  
                        Case False 
                            MsgBox(mScannedData & " Will be added to the collection!")  
                            ComboBox1.Items.Add(mScannedData)  
                            ResetValues()  
                    End Select 
            End Select 
     
        End Sub 
        Private Sub ResetValues()  
            mScannedData = "" 
            ComboBox1.Text = "" 
            ComboBox1.Focus()  
        End Sub 
        Private Sub ValidateMyData()  
            Dim lText As String 
     
            lText = ComboBox1.Text.Trim  
     
            mScannedData = lText.ToUpper  
     
        End Sub 
        Private Function DetermineExisting() As Boolean 
     
            If ComboBox1.Items.Contains(mScannedData) Then 
                DetermineExisting = True 
                Exit Function 
            Else 
                DetermineExisting = False 
            End If 
        End Function 
     
    End Class 
    • Marked as answer by qiux Wednesday, July 2, 2008 6:01 AM
    Wednesday, July 2, 2008 5:59 AM

All replies

  • Hola Quix,

    My first reader was the "wand" type, and with the reader's manual came a bunch of commands for the reader. (ie. I could set the reader to
    include a carriage return at the end of its input data.)

    So, a reader acts like a keyboard; each barcode is a set of ascii characters.

    For example, in my business, every customer order that prints has the order number included as a barcode printed at the bottom of the page.
    This helps remove human data entry errors along the process where one must enter the order number, rather, they scan a barcode.

    In addition to, there are many types of barcodes, and of which, most standard readers can read.

    In another part of my warehouse process, an employee scans the UPC-A barcode on the back of the product to load the data for the product from a data table. This reduces typos from the user because most of the time the data in the barcode is randomness, and if one has 10,000 skus in ones database, the 12 digits for each sku can become cumbersome to those employees whom have to data entry these digits hundreds of times a day.
    It is much easier to scan the barcode.

    If you want to begin barcoding, all you really need is a scanner and VB. If you want to print barcodes, there are barcode fonts avail for free or at least
    really affordable. There are also stand alone printers that have barcode fonts already installed in them. (ie. Eltron/Zebra, Datamax,Paxar) And all of these printers have commands that you can send to them from your serial port using VB.

    My barcode stations share a single data structure, and is as follows:

    1 Employee scans order number into a combo box.

    2 I pull custom customer table from database which contains MY sku name and my CUSTOMER's UPC code according to the customer associated with the order.

    3 Employee prints the barcodes associated with the order's line items.

    The barcode table has a few fields.

    1. My Sku
    2. Their Sku
    3. Their Desc. Line 1
    4. Their Desc. Line 2
    5. Their Desc. Line 3
    6. Their Desc. Line 4
    7. Their UPC-A


    What type of process would you like to achieve?





    Wednesday, July 2, 2008 4:07 AM
  • Thanks for the reply..

    Yeah, that saves a lot of work and typo error, I agree with you.

    Okay, let's say I type 123456 with that font in MS WORD and I print it, once I use barcode reader to read it to 1 text box, will it appear 123456 at there?
    Does it a built in function for the reader? so once I put the focus on any text box and then I scan the printed label, the text box will get the 123456.

    I have downloaded a font IDAutomationHC39M.ttf and got it installed on my PC.


    Wednesday, July 2, 2008 4:22 AM
  • Exactly, I had an IDAutomation Font, maybe still do, but not on this machine, not bad.

    Code 3of9 is perfect for short lengths of text.(ie UPS tracking number 1z1234561231231234)

    I scan tracking numbers off of strips of package labels into Notepad.exe.

    Many scanners are configurable. You can add a carriage return/Line feeds and function keys into the reader.

    Textboxes accept the data as regular text. I prefer to use combo boxes because i can add the value to the combo box after it is scanned.

    In my code, I use the key down event procedure to determine if a carrige return character has entered into my forms control text field.

    ie.
    Barcode Scanned Data = 123456 & enterkey


    Select Case KeyCode

    Case 13
        
            
                1. SQL the database
                2. Return result
                3. Add Value to Combo box
                
    End select


    Most readers by default will add the carriage return, so you do not have to add it in your barcode; otherwise, you will have to experiment
    with your barcode font and 2 VB events - key press and key down. These events return different argument values when they are fired.

    Also, look up the Key Ascii chart in the VB documents. It will provide all of the keycode numbers. I prefer to use uppercase in my barcodes for text.



    Wednesday, July 2, 2008 4:51 AM
  • I got your idea, that is what I want to find.
    Anyway, could you show me the code/script how to implement in vb 2005 or any related source that can be a reference for me?

    Wednesday, July 2, 2008 5:18 AM
  • Sure, let me code a quick something to get you started. I usually do not do this, but I will reply shortly.

    Can you give me "real data" samples for which you are going to use?

    ie my order number barcodes are always in the format of "123456-1234"
    Wednesday, July 2, 2008 5:24 AM
  • I very appreciated it.. :)
    let's say that I got item no 1112365-12.
    Wednesday, July 2, 2008 5:59 AM
  •  This is enough code to test your barcode scanner.
    Public Class Form1  
        Dim mScannedData As String 
     
        Private Sub ComboBox1_KeyDown(ByVal sender As ObjectByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyDown  
            Dim lResult As Boolean 
     
            Select Case e.KeyCode  
                Case 13  
     
     
                    ValidateMyData()  
     
                    lResult = DetermineExisting()  
     
                    Select Case lResult  
                        Case True 
                            MsgBox("This Item Has already been scanned!")  
                        Case False 
                            MsgBox(mScannedData & " Will be added to the collection!")  
                            ComboBox1.Items.Add(mScannedData)  
                            ResetValues()  
                    End Select 
            End Select 
     
        End Sub 
        Private Sub ResetValues()  
            mScannedData = "" 
            ComboBox1.Text = "" 
            ComboBox1.Focus()  
        End Sub 
        Private Sub ValidateMyData()  
            Dim lText As String 
     
            lText = ComboBox1.Text.Trim  
     
            mScannedData = lText.ToUpper  
     
        End Sub 
        Private Function DetermineExisting() As Boolean 
     
            If ComboBox1.Items.Contains(mScannedData) Then 
                DetermineExisting = True 
                Exit Function 
            Else 
                DetermineExisting = False 
            End If 
        End Function 
     
    End Class 
    • Marked as answer by qiux Wednesday, July 2, 2008 6:01 AM
    Wednesday, July 2, 2008 5:59 AM
  • Thanks mate.. I will try it and updated you the result..

    Appreciated that. :)
    Wednesday, July 2, 2008 6:01 AM