Azalea Software, Inc. www.azalea.com Print Code 93 Barcodes in Visual Basic Code93 in VB

Print barcodes in Visual Basic programs using Azalea Software's barcode fonts. We've already written a function that generate Code 93 barcodes in VB programs. This free VB code calculates the C and K check digits and adds the start and stop bars.

This function can be used to create an Excel macro or a Word macro. If you ask nicely, you can probably get Jerry to make one for you.

Function AzaleaCode93CheckDigits(ByVal C93 As String) As String
' C93Tools v6.0 Copyright 2008 Jerry Whiting. All rights reserved.
' Azalea Software, Inc. www.azalea.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

You may port these functions to other languages and development tools, so feel free to copy, paste, and edit the code as needed; our sole caveat is that our copyright notice must remain intact. When you port, or if you find a bug or something that needs improvement, please send us a copy so we can learn something new. (Our email address is technicalsupport at azalea dot com …and as always, AtDhVaAnNkCsE!)