Module ModMain Sub Main() Do Console.ForegroundColor = ConsoleColor.White Console.Write("Barcode: ") Console.ForegroundColor = ConsoleColor.Green Dim Code As String = Console.ReadLine If Code.Length = &HC Then Console.CursorTop -= &H1 Console.CursorLeft = &H15 Console.ForegroundColor = ConsoleColor.Red Console.WriteLine(CCC13_Checksum(Code)) Else Console.WriteLine("Error! Enter the 12 first digits of your EAN13 code.") End If Loop End Sub Private Function CCC13_Checksum(ByVal Line As String) As Byte Dim Factor As Int32 = &H3 Dim Sum As Int32 = &H0 For Index As Integer = (Line.Length - &H1) To &H0 Step -&H1 Sum = Sum + (CInt(Line.Substring(Index, &H1)) * Factor) Factor = &H4 - Factor Next Return ((&H3E8 - Sum) Mod &HA) End Function End Module