水晶报表中使用Code128制作条型码的方法
- 格式:doc
- 大小:31.50 KB
- 文档页数:2
水晶报表中使用Code128制作条型码的方法
1、下载code128的字体,下载后放到window下面的fonts目录。
2、在水晶报表里的【字段资源管理器】的【公式字段】中新建一个公式字段。点击【使
用编辑器】之后弹出【公式工作室】。
3、在【公式工作室】中的【报表自定义函数】新建一个函数保存为Code128,名字随
便定义,在代码框中输入如下代码(Basic语法):
Function Code128 ( 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
Code128 = "Ì" + strIn + strEndChr + "Î"
End Function
4、保存后,点击新建的公式字段,在自定义函数选择框内,选择刚新建的自定义函数。在【函数参数】的【值】中选择你要转换的数据库字段。或者使用编辑器直接输入:Code128 ({字段名})也可以,保存后拖到报表中即可。字体一定要选择刚安装的code128字体。
Code128(ToText((ToNumber({StockOutItem.proMPQ})),0,''))
参考:/ychchhy/article/details/6902876