This is a migrated thread and some comments may be shown as answers.

Barcodes - Code 128

1 Answer 66 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 21 Jan 2010, 09:59 AM
Hi All,

I'm generating a report that has some barcodes in it, Code 128 with checksum turned on.

When I scan the barcode it comes back in unsuprisingly with the checksum present within the barcode.  Code 128 seems to be dynamically generated of 123A B and C variants.  What is the code to check the checksum - VB if possible...

Best Regards,

Jon

1 Answer, 1 is accepted

Sort by
0
Ivan
Telerik team
answered on 21 Jan 2010, 02:25 PM
Hi Jon,

Normally there is no need to validate the barcode checksum programmatically yourself because the barcode scanner performs such validation automatically as a part of the scanning process. However if you need to compute the checksum for some other reason, Code 128 uses a weighted sum of all character values modulo 103 to produce the final check character. This can be illustrated with the following code snippet:

Function ComputeChecksum(ByVal values() As Integer) As Integer
    Dim checksum As Integer = values(0)
  
    For index As Integer = 1 To values.Length - 1
        checksum = checksum + values(index) * index
    Next
  
    checksum = checksum Mod 103
  
    Return checksum
End Function

The function from the sample code above accepts an array of encoded character values and returns the computed checksum of these values. If you have an input string of ASCII characters, you must encode it first with the Code 128 A, B or C code table, according to the Code 128 barcode specification.

If you need more information regarding this topic, there is a good article about Code 128 barcodes in Wikipedia, but a quick search with your favorite search engine might provide you more results.

Kind regards,
Ivan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
Jon
Top achievements
Rank 1
Answers by
Ivan
Telerik team
Share this question
or