Crystal reports Crystal Reports Code 128条形码打印形状而不是数字

Crystal reports Crystal Reports Code 128条形码打印形状而不是数字,crystal-reports,code128,Crystal Reports,Code128,我有一个字体为128的公式字段,用于打印用户输入的字符串 除两(2)个零相邻外,每次打印都很好。但当它打印100的时候,事情是好的,但如果我打印1000,它会在条形码中打印一些矩形。同样,1001可以很好地打印,10001可以用矩形打印 以下是公式字段: @QuantityBarCode ' http://support.wisys.com/documentation/Crystal_Report_IDAutomation_Basic_Syntax_Barcode_Settings.htm D

我有一个字体为128的公式字段,用于打印用户输入的字符串

除两(2)个零相邻外,每次打印都很好。但当它打印100的时候,事情是好的,但如果我打印1000,它会在条形码中打印一些矩形。同样,1001可以很好地打印,10001可以用矩形打印

以下是公式字段:

@QuantityBarCode

' http://support.wisys.com/documentation/Crystal_Report_IDAutomation_Basic_Syntax_Barcode_Settings.htm

Dim DataToEncode As String
DataToEncode = Trim({@Quantity}) ' Quantity
Dim PrintableString As String
Dim DataToFormat As String
Dim WeightedTotal As Number
Dim CurrentValue As Number
Dim CheckDigitValue As Number
Dim C128CheckDigit As String
Dim StringLength As Number
Dim I As Number
Dim CurrentCharNum As Number
Dim CurrentEncoding As String
Dim C128Start As String
Dim CorrectFNC As Number
Dim CurrentChar As String
CorrectFNC = 0
PrintableString = ""
DataToFormat = DataToEncode
DataToEncode = ""

'Here we select character set A, B or C for the START character
StringLength = Len(DataToFormat)
CurrentCharNum = Asc(Mid(DataToFormat, 1, 1))
If CurrentCharNum < 32 Then C128Start = Chr(203)
If CurrentCharNum > 31 And CurrentCharNum < 127 Then C128Start = Chr(204)
If ((StringLength > 4) And IsNumeric(Mid(DataToFormat, 1, 4))) Then C128Start = Chr(205)

'202 & 212-215 is for the FNC1, with this Start C is mandatory
If CurrentCharNum = 202 Then C128Start = Chr(205)
If CurrentCharNum = 212 Then C128Start = Chr(205)
If CurrentCharNum = 213 Then C128Start = Chr(205)
If CurrentCharNum = 214 Then C128Start = Chr(205)
If CurrentCharNum = 215 Then C128Start = Chr(205)
If C128Start = Chr(203) Then CurrentEncoding = "A"
If C128Start = Chr(204) Then CurrentEncoding = "B"
If C128Start = Chr(205) Then CurrentEncoding = "C"

For I = 1 To StringLength
    'check for FNC1 in any set which is ASCII 202 and ASCII 212-215
    CurrentCharNum = Asc(Mid(DataToFormat, I, 1))
If ((CurrentCharNum = 202) Or (CurrentCharNum = 212) Or (CurrentCharNum = 213) Or (CurrentCharNum = 214) Or (CurrentCharNum = 215)) Then
        DataToEncode = DataToEncode & Chr(202)
    'check for switching to character set C
ElseIf ((I < StringLength - 2) And (IsNumeric(Mid(DataToFormat, I, 1))) And (IsNumeric(Mid(DataToFormat, I + 1, 1))) And (IsNumeric(Mid(DataToFormat, I, 4)))) Or ((I < StringLength) And (IsNumeric(Mid(DataToFormat, I, 1))) And (IsNumeric(Mid(DataToFormat, I + 1, 1))) And (CurrentEncoding = "C")) Then
    'switch to set C if not already in it
        If CurrentEncoding <> "C" Then DataToEncode = DataToEncode & Chr(199)
        CurrentEncoding = "C"
        CurrentChar = Mid(DataToFormat, I, 2)
        CurrentValue = Val(CurrentChar)
    'set the CurrentValue to the number of String CurrentChar
If (CurrentValue < 95 And CurrentValue > 0) Then DataToEncode = DataToEncode &                                                                                          Chr(CurrentValue + 32)
        If CurrentValue > 94 Then DataToEncode = DataToEncode & Chr(CurrentValue + 100)
        If CurrentValue = 0 Then DataToEncode = DataToEncode & Chr(194)
        I = I + 1
    'check for switching to character set A
ElseIf (I <= StringLength) And ((Asc(Mid(DataToFormat, I, 1)) < 31) Or  ((CurrentEncoding = "A") And (Asc(Mid(DataToFormat, I, 1)) > 32 And (Asc(Mid(DataToFormat, I, 1))) < 96))) Then
    'switch to set A if not already in it
        If CurrentEncoding <> "A" Then DataToEncode = DataToEncode & Chr(201)
        CurrentEncoding = "A"
    'Get the ASCII value of the next character
        CurrentCharNum = Asc(Mid(DataToFormat, I, 1))
        If CurrentCharNum = 32 Then
            DataToEncode = DataToEncode & Chr(194)
        ElseIf CurrentCharNum < 32 Then
            DataToEncode = DataToEncode & Chr(CurrentCharNum + 96)
        ElseIf CurrentCharNum > 32 Then
            DataToEncode = DataToEncode & Chr(CurrentCharNum)
        End If
    'check for switching to character set B
 ElseIf (I <= StringLength) And (((Asc(Mid(DataToFormat, I, 1))) > 31) And ((Asc(Mid(DataToFormat, I, 1)))) < 127) Then
    'switch to set B if not already in it
        If CurrentEncoding <> "B" Then DataToEncode = DataToEncode & Chr(200)
        CurrentEncoding = "B"
    'Get the ASCII value of the next character
        CurrentCharNum = Asc(Mid(DataToFormat, I, 1))
        If CurrentCharNum = 32 Then
            DataToEncode = DataToEncode & Chr(194)
        Else
            DataToEncode = DataToEncode & Chr(CurrentCharNum)
        End If
    End If
Next I

'<<<< Calculate Modulo 103 Check Digit >>>>
WeightedTotal = Asc(C128Start) - 100
StringLength = Len(DataToEncode)
For I = 1 To StringLength
    CurrentCharNum = Asc(Mid(DataToEncode, I, 1))
    If CurrentCharNum < 135 Then CurrentValue = CurrentCharNum - 32
    If CurrentCharNum > 134 Then CurrentValue = CurrentCharNum - 100
    If CurrentCharNum = 194 Then CurrentValue = 0
    CurrentValue = CurrentValue * I
    WeightedTotal = WeightedTotal + CurrentValue
    If CurrentCharNum = 32 Then CurrentCharNum = 194
    PrintableString = PrintableString & Chr(CurrentCharNum)
Next I
CheckDigitValue = (WeightedTotal Mod 103)
If CheckDigitValue < 95 And CheckDigitValue > 0 Then C128CheckDigit = Chr(CheckDigitValue + 32)
If CheckDigitValue > 94 Then C128CheckDigit = Chr(CheckDigitValue + 100)
If CheckDigitValue = 0 Then C128CheckDigit = Chr(194)
DataToEncode = ""

' Final Barcode format
Formula = C128Start & PrintableString & C128CheckDigit & Chr(206) & " "
'http://support.wisys.com/documentation/Crystal_Report_IDAutomation_Basic_Syntax_Barcode_Settings.htm
Dim DataToEncode作为字符串
DataToEncode=修剪({@Quantity})数量
将可打印字符串设置为字符串
Dim DataToFormat作为字符串
按数字计算的总重量
将当前值设置为数字
Dim CheckDigitValue作为数字
Dim C128校验位为字符串
将字符串长度设置为数字
Dim I作为数字
Dim CurrentCharNum作为数字
Dim CurrentEncoding作为字符串
Dim C128以字符串形式启动
Dim校正FNC As编号
Dim CurrentChar作为字符串
修正fnc=0
PrintableString=“”
DataToFormat=DataToEncode
DataToEncode=“”
'这里我们选择字符集A、B或C作为起始字符
StringLength=Len(数据格式)
CurrentCharNum=Asc(Mid(DataToFormat,1,1))
如果CurrentCharNum<32,则C128Start=Chr(203)
如果CurrentCharNum>31且CurrentCharNum<127,则C128Start=Chr(204)
如果((StringLength>4)和IsNumeric(Mid(DataToFormat,1,4)),则C128Start=Chr(205)
'202&212-215适用于FNC1,此Start C是强制性的
如果CurrentCharNum=202,则C128Start=Chr(205)
如果CurrentCharNum=212,则C128Start=Chr(205)
如果CurrentCharNum=213,则C128Start=Chr(205)
如果CurrentCharNum=214,则C128Start=Chr(205)
如果CurrentCharNum=215,则C128Start=Chr(205)
如果C128Start=Chr(203),则CurrentEncoding=“A”
如果C128Start=Chr(204),则CurrentEncoding=“B”
如果C128Start=Chr(205),则CurrentEncoding=“C”
对于I=1到StringLength
'检查ASCII 202和ASCII 212-215的任何集合中的FNC1
CurrentCharNum=Asc(Mid(数据格式,I,1))
如果((CurrentCharNum=202)或(CurrentCharNum=212)或(CurrentCharNum=213)或(CurrentCharNum=214)或(CurrentCharNum=215)),则
DataToEncode=DataToEncode&Chr(202)
'检查是否切换到字符集C
ElseIf((I0),则DataToEncode=DataToEncode&Chr(CurrentValue+32)
如果CurrentValue>94,则DataToEncode=DataToEncode&Chr(CurrentValue+100)
如果CurrentValue=0,则DataToEncode=DataToEncode&Chr(194)
I=I+1
'检查是否切换到字符集A
ElseIf(i32和Asc(Mid(DataToFormat,I,1)))<96)),然后
'如果不在其中,则切换到设置
如果CurrentEncoding“A”,则DataToEncode=DataToEncode&Chr(201)
CurrentEncoding=“A”
'获取下一个字符的ASCII值
CurrentCharNum=Asc(Mid(数据格式,I,1))
如果CurrentCharNum=32,则
DataToEncode=DataToEncode&Chr(194)
ElseIf CurrentCharNum<32则
DataToEncode=DataToEncode&Chr(CurrentCharNum+96)
ElseIf CurrentCharNum>32则
DataToEncode=DataToEncode&Chr(CurrentCharNum)
如果结束
'检查是否切换到字符集B
ElseIf(i31)和((Asc(Mid(DataToFormat,I,1)))<127)然后
'如果不在其中,则切换到设置B
如果CurrentEncoding“B”,则DataToEncode=DataToEncode&Chr(200)
CurrentEncoding=“B”
'获取下一个字符的ASCII值
CurrentCharNum=Asc(Mid(数据格式,I,1))
如果CurrentCharNum=32,则
DataToEncode=DataToEncode&Chr(194)
其他的
DataToEncode=DataToEncode&Chr(CurrentCharNum)
如果结束
如果结束
接下来我
'>
加权总=Asc(C128Start)-100
StringLength=Len(数据加密)
对于I=1到StringLength
CurrentCharNum=Asc(Mid(DataToEncode,I,1))
如果CurrentCharNum<135,则CurrentValue=CurrentCharNum-32
如果CurrentCharNum>134,则CurrentValue=CurrentCharNum-100
如果CurrentCharNum=194,则CurrentValue=0
CurrentValue=CurrentValue*I
加权总和=加权总和+当前值
如果CurrentCharNum=32,则CurrentCharNum=194
PrintableString=PrintableString&Chr(CurrentCharNum)
接下来我
CheckDigitValue=(加权总模块103)
如果CheckDigitValue<95且CheckDigitValue>0,则C128CheckDigit=Chr(CheckDigitValue+32)
如果CheckDigitValue>94,则C128CheckDigit=Chr(CheckDigitValue+100)
如果CheckDigitValue=0,则C128CheckDigit=Chr(194)
DataToEncode=“”
'最终条形码格式
公式=C128开始和可打印字符串&C128校验位&Chr(206)&“”
图像显示1000为文本(用户输入),条形码以矩形打印,我还将条形码文本添加到右下角,以显示编码时条形码文本的外观。我注意到,当我得到这个奇怪的形状时,文本中似乎有星号

任何帮助都将不胜感激:)


我知道可能已经太晚了,但如果有人有类似的问题,我会在将来回答这个问题

此代码是为IDAutomationC128M.ttf字体提供的,该字体在ascii 194上有字符,而字体代码128.ttf没有字符
DataToEncode = DataToEncode & Chr(194)
DataToEncode = DataToEncode & Chr(207)
  Function (StringVar input)
    NumberVar CheckDigit := 0;
    NumberVar i := 0;
    StringVar BarCodeOutput := "";
    StringVar BarCodeInput := input;
    StringVar BarCodeTemp := "";
    NumberVar SingleByte := 0;
    BarCodeInput := Uppercase(input);
    For i := 1 To Len(BarCodeInput) Step 1 Do
        (SingleByte := Asc(Mid(BarCodeInput, i,1));
            If SingleByte >=0 And SingleByte < 32 Then
                BarCodeTemp := BarCodeTemp + Chr(SingleByte +64)    
            Else if SingleByte > 31 And SingleByte < 127 Then
                BarCodeTemp := BarCodeTemp + Chr(SingleByte - 32)       
            Else
                BarCodeTemp := BarCodeTemp + ""
        );

    For i := 1 To Len(BarCodeTemp) Step 1 Do
        (SingleByte := Asc(Mid(BarCodeTemp, i,1));
            CheckDigit := (CheckDigit + (SingleByte * i)) Mod 103;
        );
    BarCodeTemp := BarCodeTemp + Chr(CheckDigit);

    For i := 1 To Len(BarCodeTemp) Step 1 Do
        (SingleByte := Asc(Mid(BarCodeTemp, i, 1));
            If SingleByte =0 Then
                BarCodeOutput := Chr(206)       
            Else if SingleByte > 0 And SingleByte < 94 Then
                BarCodeOutput := BarCodeOutput + Chr(SingleByte + 32)
            Else
                BarCodeOutput := BarCodeOutput + Chr(SingleByte + 103)
        );

    Chr(203) + BarCodeOutput + Chr(206)