Need Help & Adivise In EAN13 generation

derozza

New member
Joined
Jan 18, 2011
Messages
3
Programming Experience
Beginner
Hi all i need help in generating my ean13 generator.

First step that i made, by generating product code without check number.
VB.NET:
Private Function ean_complete() As String
        Dim conn As New MySqlConnection
        conn.ConnectionString = (ConfigurationManager.ConnectionStrings.Item("ItemListing").ToString)
        Dim cnSQL As String
        Dim i As Integer
        Dim cmSQL As MySqlCommand
        conn.Open()

        cnSQL = "Select * From Ean13" & _
                " Where deptcode = '" & txtDeptCode.Text & "'"
        Dim da As New MySqlDataAdapter(cnSQL, conn)
        Dim dt As New DataTable
        da.Fill(dt)
        Dim temp As String = ""
        Dim temp1 As String = ""
        Dim temp0 As String = ""
        temp = dt.Rows(0).Item("inhouse")
        temp1 = dt.Rows(0).Item("Deptcode")
        For i = 0 To dt.Rows(0).Item("len") - (dt.Rows(0).Item("item").ToString.Length + temp.Length) - 1
            temp0 = temp0 + "0"
        Next
        Dim newseq As Integer = CInt(dt.Rows(0).Item("seq")) + 1
        cnSQL = "UPDATE EAN13 SET item = '" & CStr(newseq) & "'"
        cmSQL = New MySqlCommand(cnSQL, conn)
        cmSQL.ExecuteNonQuery()
        Return CStr(dt.Rows(0).Item("inhouse")) + dt.Rows(0).Item("Deptcode") + temp0 + CStr(dt.Rows(0).Item("item"))
        conn.Close()
    End Function

after i got this 12digit product code i need to generate check number which i'm stuck for 2 day. Example of my result is "200001000012*" * = check number

Now next i need to generate full product code with check number that show into text box.

But i loss until this stage. Anyone can advise me.. thank u
 
Hi

i have a function that calculate the value chekcsum from your EAN13 code compound of 12 and after that concatenate with the checksum value

Function ChecksumEAN13(ByVal barcode As String) As Integer
Dim multiplier As Integer
Dim total As Integer
total = 0
multiplier = 3
Dim carr() As Char
carr = barcode.ToCharArray()
Array.Reverse(carr)
barcode = CStr(carr)
For Each el As Char In barcode
If el >= "0" And el <= "9" Then
total = total + Val(el) * multiplier
If multiplier = 3 Then multiplier = 1 Else multiplier = 3
End If
Next
ChecksumEAN13 = 10 - (total Mod 10)
End Function

hope it helps
 
Back
Top