|
'this only does 12 digit barcodes for now...
'if your interested in how this works go to
'www.howstuffworks.com/upc.htm
'thats where i got most of my information...just thought it
'would be nice to have a quick funcion to do the math for me
'and figured i should share ;)
Public Class Barcode
Public Shared Function VerifyBarcodeInfo(ByVal info As String) As Boolean
Return ((((((Val(info.Chars(0)) + Val(info.Chars(2)) + Val(info.Chars(4)) + Val(info.Chars(6)) + _
Val(info.Chars(8)) + Val(info.Chars(10))) * 3) + (Val(info.Chars(1)) + Val(info.Chars(3)) + _
Val(info.Chars(5)) + Val(info.Chars(7)) + Val(info.Chars(9)))) + (Val(info.Chars(11)))) _
Mod 10) = 0)
End Function
Public Shared Function GenerateCheckDigit(ByVal theCode As String) As String
If theCode.Length = 11 Then
Return theCode & (10 - ((((Val(theCode.Chars(0)) + Val(theCode.Chars(2)) + Val(theCode.Chars(4)) + Val(theCode.Chars(6)) + Val(theCode.Chars(8)) + Val(theCode.Chars(10))) * 3) + (Val(theCode.Chars(1)) + Val(theCode.Chars(3)) + Val(theCode.Chars(5)) + Val(theCode.Chars(7)) + Val(theCode.Chars(9)))) Mod 10)).ToString
End If
End Function
End Class
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.