Using Barcode Font Code128 in Barcode Reports

Use the following steps to replace the default barcode font in reports with barcode font Code128. Code128 prints smaller barcodes than the default font (barcode font Code39QuarterInch).

Note that Infor's support of barcode font Code128 prints only the characters currently available in the default barcode font.

Note:  With Code128, Code128Narrow, and Code128VeryNarrow, a font size of 48 or greater is recommended. With Code128Wide and Code128VeryWide, a font size of 36 or greater is recommended.

When using this font, you must use English as the Windows regional setting.

These are the differences between Code 128A and Code 128B:

  • Code 128A does not support lower case characters but Code 128B does support lower case characters.
  • Code 128A can encode punctuation, the digits 0 through 9, uppercase characters (no lowercase), the standard ASCII control codes, and the special characters shown in the table below. Code 128B can encode punctuation, digits 0 through 9, upper and lower case characters, and the special characters in the table below.

We recommend that you use Code 128B; it is generally the best choice for most circumstances.

This table shows the Code 128 special characters:

ASCII Code    Code 128A    Code 128B   
32 FNC3 FNC3
33 FNC2 FNC2
34 Shift Shift
35 Code C Code C
36 Code B FNC4
37 FNC4 Code A
38 FNC1 FNC1
(FNC = Function Key)

To replace the default barcode font in reports with barcode font Code128:

  1. In Visual Studio 2008, open the .rdl file in which you want to substitute barcode font Code128 for the existing barcode font. .Rdl files are generally stored on the utility server in the TaskMan\Report folder.
  2. Include one of these functions in the rdl file:

    For Code128 A:

    Public Function GetBarCodeOutput t(ByVal inputValue As String) As String
    Dim CheckDigit As Integer = 0 
    Dim i As Integer = 0 
    Dim BarCodeOutput As String = ""
    Dim BarCodeInput As String 
    Dim BarCodeTemp  As String = ""
    Dim SingleByte  As Integer = 0 
    BarCodeInput = inputValue.ToUpper()
    For i = 1 To Len(BarCodeInput)
        SingleByte = Asc(Mid(BarCodeInput, i,1))
        BarCodeTemp = BarCodeTemp + Chr(SingleByte - 32)
    Next 
    CheckDigit = 1
    For i = 1 To Len(BarCodeTemp) 
       SingleByte = Asc(Mid(BarCodeTemp, i,1))
       CheckDigit = (CheckDigit + (SingleByte * i)) Mod 103
    Next 
    BarCodeTemp = BarCodeTemp + Chr(CheckDigit)
    For i = 1 To Len(BarCodeTemp)
        SingleByte = Asc(Mid(BarCodeTemp, i, 1))     
        If SingleByte =0 Then
           BarCodeOutput = Chr(0)
        ElseIf SingleByte > 0 And SingleByte < 94 Then
           BarCodeOutput = BarCodeOutput + Chr(SingleByte + 32)
        Else
           BarCodeOutput = BarCodeOutput + Chr(SingleByte + 103)
        End If
    Next        
    Return  "µ"+ BarCodeOutput + Chr(196)
    End Function

    For Code128 B:

    Public Function GetBarCodeOutput(ByVal inputValue As String) As String
    Dim CheckDigit As Integer = 0 
    Dim i As Integer = 0 
    Dim BarCodeOutput As String = ""
    Dim BarCodeInput As String 
    Dim BarCodeTemp  As String = ""
    Dim SingleByte  As Integer = 0 
    BarCodeInput = inputValue.ToUpper()
    For i = 1 To Len(BarCodeInput)
        SingleByte = Asc(Mid(BarCodeInput, i,1))
        BarCodeTemp = BarCodeTemp + Chr(SingleByte - 32)
    Next 
    CheckDigit = 1
    For i = 1 To Len(BarCodeTemp) 
       SingleByte = Asc(Mid(BarCodeTemp, i,1))
       CheckDigit = (CheckDigit + (SingleByte * i)) Mod 103
    Next 
    BarCodeTemp = BarCodeTemp + Chr(CheckDigit)
    For i = 1 To Len(BarCodeTemp) 
        SingleByte = Asc(Mid(BarCodeTemp, i, 1))     
        If SingleByte =0 Then
           BarCodeOutput = Chr(0)
        ElseIf SingleByte > 0 And SingleByte < 94 Then
           BarCodeOutput = BarCodeOutput + Chr(SingleByte + 32)
        Else
           BarCodeOutput = BarCodeOutput + Chr(SingleByte + 103)
        End If
    Next        
    Return "¶"+ BarCodeOutput + Chr(196)
    End Function
    	
  3. Right-click a barcode object and select Edit Formula. In the Formula Editor, you will see a formula similar to this:
    ="*" & Replace(UCase(Trim(Fields!item.Value)),"", "_") & "*"

    In this example, Trim(Fields!item.Value) is a database field that is replaced with a barcode. Reports can also include formulas for stored procedures

  4. Replace the one-line formula with a call to the function you added in step 2:
    =Code.GetBarCodeOutput(FieldValue)
    	

    where FieldValue is the database field or stored procedure field that is replaced with a barcode, for example:

    =Code.GetBarCodeOutput(Trim(Fields!item.Value))
  5. To close the Formula Editor, click the Close button.
  6. Right-click the barcode object and select Format Field.
  7. On the Font tab, select the appropriate font and font size. For example, select Font Code128 and Size 48.
  8. Click OK.
  9. Save the .rdl file and test the report.