Function Azalea_Code_128_C(ByVal yourData As String) As String ' C128Tools 29may12 jwhiting ' Copyright 2012 Azalea Software, Inc. All rights reserved. www.azaleabarcodes.com ' Creating a Code 128 code set C barcode using C128Tools. ' Your input, yourData, is a string to be encoded as a Code 128 code set C symbol. ' yourData must be the Code 128 code set C character set. Input error checking is your responsibility. Dim temp As String ' a temporary placeholder Dim checkDigitSubtotal As Integer ' a check digit throwaway Dim i As Integer ' our loop counter Dim fontString As String ' a temporary placeholder Dim chunk As String ' loop chunk ' seed the variables fontString = Chr(183) ' code set C start glyph checkDigitSubtotal = 105 ' code set C start checkdigit value temp = yourData ' 2 character chunks ' pad odd length input with a leading zero goesHere PRN ' Calculate the Code 128 mod 103 check digit For i = 1 To Len(yourData) / 2 chunk = Left$(temp, 2) checkDigitSubtotal = checkDigitSubtotal + Val(chunk) * i 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 ' Put together the final output string ' code set C start bar, the encoded string, check digit, stop bar Select Case checkDigitSubtotal Case 0 Azalea_Code_128_C = fontString & Chr(206) & Chr(196) Case 1 To 93 Azalea_Code_128_C = fontString & Chr(checkDigitSubtotal + 32) & Chr(196) Case Is > 93 Azalea_Code_128_C = fontString & Chr(checkDigitSubtotal + 103) & Chr(196) End Select End Function