Function barCode(ByVal codeStr)
'code 39码制条形码
codeStr=UCase(codeStr)
If emp(codeStr) Then Exit Function Else codeStr=UCase(cStr(codeStr))
Dim s : s=codeStr
If Not regTest(s, "^[abcdefghijklmnopqrstuvwxyz1234567890 +\-%$./]{1,40}$") Then Exit Function Else s="*"&codeStr&"*"
s=Replace(s,"0","_|_|__||_||_|")
s=Replace(s,"1","_||_|__|_|_||")
s=Replace(s,"2","_|_||__|_|_||")
s=Replace(s,"3","_||_||__|_|_|")
s=Replace(s,"4","_|_|__||_|_||")
s=Replace(s,"5","_||_|__||_|_|")
s=Replace(s,"7","_|_|__|_||_||")
s=Replace(s,"6","_|_||__||_|_|")
s=Replace(s,"8","_||_|__|_||_|")
s=Replace(s,"9","_|_||__|_||_|")
s=Replace(s,"A","_||_|_|__|_||")
s=Replace(s,"B","_|_||_|__|_||")
s=Replace(s,"C","_||_||_|__|_|")
s=Replace(s,"D","_|_|_||__|_||")
s=Replace(s,"E","_||_|_||__|_|")
s=Replace(s,"F","_|_||_||__|_|")
s=Replace(s,"G","_|_|_|__||_||")
s=Replace(s,"H","_||_|_|__||_|")
s=Replace(s,"I","_|_||_|__||_|")
s=Replace(s,"J","_|_|_||__||_|")
s=Replace(s,"K","_||_|_|_|__||")
s=Replace(s,"L","_|_||_|_|__||")
s=Replace(s,"M","_||_||_|_|__|")
s=Replace(s,"N","_|_|_||_|__||")
s=Replace(s,"O","_||_|_||_|__|")
s=Replace(s,"P","_|_||_||_|__|")
s=Replace(s,"Q","_|_|_|_||__||")
s=Replace(s,"R","_||_|_|_||__|")
s=Replace(s,"S","_|_||_|_||__|")
s=Replace(s,"T","_|_|_||_||__|")
s=Replace(s,"U","_||__|_|_|_||")
s=Replace(s,"V","_|__||_|_|_||")
s=Replace(s,"W","_||__||_|_|_|")
s=Replace(s,"X","_|__|_||_|_||")
s=Replace(s,"Y","_||__|_||_|_|")
s=Replace(s,"Z","_|__||_||_|_|")
s=Replace(s,"-","_|__|_|_||_||")
s=Replace(s,"*","_|__|_||_||_|")
s=Replace(s,"/","_|__|__|_|__|")
s=Replace(s,"%","_|_|__|__|__|")
s=Replace(s,"+","_|__|_|__|__|")
s=Replace(s,".","_||__|_|_||_|")
s=Replace(s," ","_|__||_|_||_|")
s=Replace(s,"$","_|__|__|__|_|")
s=Replace(s, "_", "<i></i>")
s=Replace(s, "|", "<b></b>")
barCode="<style>div.barcode{clear:both;margin:0;padding:0;width:auto !important;background:#fff;}div.barcode i,div.barcode b{display:block;float:left;height:50px;font-size:0;overflow:hidden;}div.barcode i{width:2px;background:#fff;}div.barcode b{width:0;border-left:2px solid #000;}div.barcode div{clear:both;font-family:verdana;font-size:14px;line-height:20px;letter-spacing:25px;color:#333;}</style><div class=""barcode"">"&s&"<div>"&codeStr&"</div></div>"
End Function
Function regTest(ByVal str, p)
Dim re
Set re = New RegExp
re.Pattern = p
re.IgnoreCase = true
re.Global = true
regTest = re.Test(str)
End Function