天天看點

winform水晶報表使用code128條形碼掃描列印

http://hi.baidu.com/szwebman/item/1dec968783a7c019c216271b?qq-pf-to=pcqq.c2c

1、在水晶報表裡,建立一個公式字段。點選【使用編輯器】之後彈出【公式工作室】。

2、在【公式工作室】中的【報表自定義函數】建立一個函數,在代碼框中輸入如下代碼(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文法】進行編譯儲存。 

3、點選建立的公式字段,在自定義函數選擇框内,選擇剛建立的自定義函數。在【函數參數】的【值】中選擇你要轉換的資料庫字段。

4、将公式字段拖動到報表設計視圖之後檢查字型類型是否為Code 128

繼續閱讀