VB icon

calculate the EAN ( barcode) check digit

Email
Submitted on: 1/22/2015 9:38:00 AM
By: Michel Posseth (from psc cd)  
Level: Intermediate
User Rating: By 3 Users
Compatibility: VB 6.0
Views: 1365
 
     ever made a program capable of showing barcodes ? if you did than you`ve been there ,,, at the oficial EAN standards site,, than you would have seen how to calculate the check digit. they hold the standard they publish that standard also on their website ,,, http://www.ean-int.org/index800.html i never found code in VB that calculates the check digit ,, so my conclusion is that it was hold for comercial reassons ( there are lots of controls out there for a lot of monney :-) so i donate this M. Posseth code to the public and make it public domain ,,, uhmmm votes would be apreciated :-)
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: calculate the EAN ( barcode) check digit
' Description:ever made a program capable of showing barcodes ? 
if you did than you`ve been there ,,, at the oficial EAN standards site,, than you would have seen how to calculate the check digit.
they hold the standard they publish that standard also on their website ,,, 
http://www.ean-int.org/index800.html
i never found code in VB that calculates the check digit ,, so my conclusion is that it was hold for comercial reassons ( there are lots of controls out there for a lot of monney :-) 
so i donate this M. Posseth code to the public and make it public domain ,,, 
uhmmm votes would be apreciated :-) 
' By: Michel Posseth (from psc cd)
'
' Inputs:13 digit EAN code ( manufacterer number , parts number )
'
' Returns:14 digit EAN code ( calculates the check digit )
'**************************************

Private Function CalcEanMetcontrole(ByVal EAN13Digit As String) As String
Dim Explodestring As String
Dim DigArray
Dim Digit As Variant
Dim factor As Integer
Dim Standin As Integer
Dim som As Integer
Dim CG As Integer
Explodestring = Left$(Replace(StrConv(EAN13Digit, vbUnicode), vbNullChar, _
","), Len(EAN13Digit) * 2 - 1)
DigArray = Split(Explodestring, ",", -1, 1)
factor = 3
For Each Digit In DigArray
Standin = CInt(Digit)
som = som + (Standin * factor)
factor = 4 - factor
Next
If Right$(CStr(som), 1) = 0 Then
CG = 0
Else
CG = 10 - Right$(som, 1)
End If
CalcEanMetcontrole = Trim$(EAN13Digit & CStr(CG))
End Function


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.