Function AzaleaCode93CheckDigits(ByVal C93 As String) As String 'Azalea Code 39 Copyright 2016 Azalea Software, Inc. Azalea Software, Inc. www.azaleabarcodes.com ' The input, C93, is a string consisting of the 47-character version ' of Code 93 with the start and stop bars (*). ' The output, AzaleaCode93CheckDigits, is the input string, the C and K mod 47 ' check digits, and the start and stop bars. Dim charSet As String ' mod 47 lookup table Dim i As Integer ' loop counter Dim Rev As String ' reverser Dim indice() As Byte ' indicator Dim check1 ' first check digit (C) Dim check2 ' second check digit (K) charSet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%abcd" ' This reverses the input For i = Len(C93) To 1 Step -1 Rev = Rev & Mid(C93, i, 1) Next ' This reserves a place for the first check digit which ' will be part of the array for the second check digit calculation ReDim indice(1 To Len(C93) + 1) ' We give an indice between 0-46 to every element of the Rev array ' Each indice corresponds to the position of each element of the Rev string in charSet For i = 1 To Len(Rev) indice(i + 1) = InStr(1, charSet, Mid(Rev, i, 1)) - 1 Next ' This creates the first check digit, C check digit For i = 2 To Len(Rev) + 1 check1 = check1 + ((i - 1) Mod 20) * indice(i) Next i ' C check digit check1 = check1 Mod 47 indice(1) = check1 ' This creates the second check digit, K check digit For i = 1 To Len(Rev) + 1 check2 = check2 + (i Mod 15) * indice(i) Next i ' K check digit check2 = check2 Mod 47 ' Build the output string: start bar, input string, C and K check digits and stop bar AzaleaCode93CheckDigits = "<" & C93 & Mid(charSet, check1 + 1, 1) & Mid(charSet, check2 + 1, 1) & ">" End Function