Access开发培训
网站公告
·Access专家课堂QQ群号:151711184    ·Access快速开发平台下载地址及教程    ·欢迎加入Access专家课堂微信群!    ·如何快速搜索本站文章|示例|资料    
您的位置: 首页 > 技术文章 > Access数据库-模块/函数/VBA

使用128条码字体生成Code128C条码

时 间:2010-10-13 14:02:51
作 者:朱亦文   ID:61  城市:岳阳
摘 要:使用code128.ttf字体生成Code128C条码
正 文:

Function ToCode128C(ByVal s As String) As String
' zhuyiwen 2010.10.12
' 使用code128.ttf字体生成Code128C条码
Dim ns As String
Dim total As Long
If Len(s) > 0 And IsNumeric(s) Then
total = 105 ' Start Code
If Len(s) Mod 2 > 0 Then s = s + "0" ' 不足偶数位补0
Dim i As Integer, l As Integer
l = Len(s) \ 2
For i = 0 To l - 1
ns = ns + getChar(Mid(s, i * 2 + 1, 2))
total = total + (i + 1) * Val(Mid(s, i * 2 + 1, 2))
Next

Dim checkCode As String '生成验证码
checkCode = "" & (total Mod 103)

ns = ChrW(205) + ns + getChar(checkCode) + ChrW(206)
ToCode128C = ns
End If
End Function

Function getChar(ByVal s As String) As String
Dim c As Integer

c = Val(s)
If c = 0 Then
getChar = " "
ElseIf c < 95 Then
getChar = Chr(Asc("!") + c - 1)
Else
getChar = ChrW(100 + c)
End If

End Function

 



Access软件网官方交流QQ群 (群号:483923997)       Access源码网店

常见问答:

技术分类:

相关资源:

专栏作家

关于我们 | 服务条款 | 在线投稿 | 友情链接 | 网站统计 | 网站帮助