SAP B1:水晶報表中用Code128製做條型碼的方法

1、在【文件系統】中新建一個【Fonts文件夾】,而後添加【Code128.ttf】文件。數據庫

2、在水晶報表裏的【字段資源管理器】的【公式字段】中新建一個公式字段。點擊【使用編輯器】以後彈出【公式工做室】。編輯器

3、在【公式工做室】中的【報表自定義函數】新建一個函數,在代碼框中輸入以下代碼(VB代碼):函數

 
Function fncGetCd128SetB ( strIn As string ) As String
    
    Dim intLoop As Number
    Dim intPosition as Number
    Dim intTotalVal as Number
    Dim strOut as String
    Dim strSpChr as String
    Dim strEndChr as String
    Dim intEndNo as Number
    
    strOut = ""
    
    for  intLoop = 0 to Len(strIn) - 1
        intPosition = intLoop + 1
        strSpChr = Mid(strIn, intPosition, 1)
        intTotalVal = intTotalVal + (Asc(strSpChr) - 32) * intPosition
    next
    
    intTotalVal = intTotalVal + 104
    
    intTotalVal = intTotalVal mod 103
    
    If intTotalVal >= 95 Then 
        Select Case intTotalVal 
            Case 95 
                strEndChr = "Ã" 
            Case 96 
                strEndChr = "Ä" 
            Case 97 
                strEndChr = "Å" 
            Case 98 
                strEndChr = "Æ" 
            Case 99 
                strEndChr = "Ç" 
            Case 100 
                strEndChr = "È" 
            Case 101 
                strEndChr = "É" 
            Case 102 
                strEndChr = "Ê" 
        End Select 
    Else 
        intTotalVal = intTotalVal + 32 
        strEndChr = Chr(intTotalVal) 
    End If 

    fncGetCd128SetB = "Ì" + strIn + strEndChr + "Î"

End Function

選擇【Basic語法】進行編譯保存。oop

4、點擊新建的公式字段,在自定義函數選擇框內,選擇剛新建的自定義函數。在【函數參數】的【值】中選擇你要轉換的數據庫字段。字體

5、將公式字段拖動到報表設計視圖以後檢查字體類型是否爲Code 128。spa

參考:https://blog.csdn.net/ychchhy/article/details/6902876.net

相關文章
相關標籤/搜索