Option Explicit Function Azalea_GS1_128_C(ByVal yourData As String) As String ' C128Tools v6.0 24apr07 rev 001 jwhiting ' Copyright 2007 Azalea Software, Inc. All rights reserved. www.azalea.com ' yourData is a string to be encoded as a GS1-128 code set C symbol. ' yourData must be an even number of digits long. If not, pad it with a leading zero first. ' Format the output, Azalea_GS1_128_C, using one of Azalea Software's Code 128 barcode fonts. Dim fontString As String ' encoded data Dim temp As String ' throwaway variable Dim checkDigitSubtotal As Integer ' weighted subtotal Dim chunk As String ' loop variable Dim i As Integer ' just a counter ' seed the variables fontString = Chr(183) & Chr(205) ' code set C start & FNC1 glyphs checkDigitSubtotal = 207 ' code set C start & FNC1 checkdigit values (105 + 102 = 207) temp = yourData ' 2 character chunks ' pad odd length input with a leading zero goesHereLater ' first do the mod 103 check digit calculation ' then map into the Azalea Code 128 character set For i = 1 To Len(yourData) / 2 chunk = Left$(temp, 2) checkDigitSubtotal = checkDigitSubtotal + Val(chunk) * (i + 1) Select Case Val(chunk) Case 0 fontString = fontString + Chr(206) Case 1 To 93 fontString = fontString & Chr(Val(chunk) + 32) Case Is > 93 fontString = fontString & Chr(Val(chunk) + 103) End Select temp = Right$(temp, Len(temp) - 2) Next i checkDigitSubtotal = checkDigitSubtotal Mod 103 ' build the output string ' code set C start bar, the encoded string, check digit, stop bar Select Case checkDigitSubtotal Case 0 Azalea_GS1_128_C = fontString & Chr(194) & Chr(196) Case 1 To 93 Azalea_GS1_128_C = fontString & Chr(checkDigitSubtotal + 32) & Chr(196) Case Is > 93 Azalea_GS1_128_C = fontString & Chr(checkDigitSubtotal + 103) & Chr(196) End Select End Function