Function Azalea_GS1128B(ByVal yourData As String) As String ' C128Tools 29feb08 jwhiting ' Copyright 2008 Azalea Software, Inc. All rights reserved. www.azalea.com ' yourData is a string to be encoded as a GS1-128 code set B symbol. ' Input error checking is your responsibility. ' Format the output, Azalea_GS1128B, using one of Azalea Software's Code 128 barcode fonts. Dim fontString As String ' encoded data Dim chunk As String ' loop variable Dim i As Integer ' just a counter Dim checkDigitSubtotal As Integer ' weighted subtotal Dim e As Integer ' placeholder variable ' seed the variables fontString = Chr(182) & Chr(205) ' code set B start & FNC1 glyphs checkDigitSubtotal = 206 ' code set B start & FNC1 checkdigit values (104 + 102 = 206) ' map the input string into the Azalea Code 128 character set For i = 1 To Len(yourData) Step 1 chunk = Mid(yourData, i, 1) Select Case Asc(chunk) ' map from above ASCII 200 placeholders to actual character assignments Case Is > 200 fontString = fontString & Chr(Asc(chunk) - 35) ' The space character is at ASCII 194 because TrueType ' doesn't allow a glyph in the ASCII 32 slot Case Is = 32 fontString = fontString & Chr(206) Case Else fontString = fontString & chunk End Select Next i ' the mod 103 check digit calculation For i = 1 To Len(yourData) e = Asc(Mid(yourData, i, 1)) - 32 If e <> 142 Then checkDigitSubtotal = checkDigitSubtotal + (e * i) ' if it doesn't beep ((e * i) + 1) End If Next i checkDigitSubtotal = checkDigitSubtotal Mod 103 ' build the output string ' code set A start bar, the encoded string, check digit, stop bar Select Case checkDigitSubtotal Case 0 Azalea_GS1128B = fontString & Chr(194) & Chr(196) Case 1 To 93 Azalea_GS1128B = fontString & Chr(checkDigitSubtotal + 32) & Chr(196) Case Is > 93 Azalea_GS1128B = fontString & Chr(checkDigitSubtotal + 103) & Chr(196) End Select ' The output, Azalea_GS1128B, is formatted using one of Azalea Software's Code 128 fonts. ' For example, B1=Azalea_GS1128B(A1) ' Or put another way, yourContainer.text=Azalea_GS1128B(yourInputString) End Function