最新消息:重新回归WordPress,我要比较认真的开始更新我的博客了。

CODE 128条码生成ASP版

程序问题 hanlei 1621浏览

又是条码,以前因为工作可能会用到研究过.现在还是一样,公司要把订单号用条码打印出来.
网上有EAN13的ASP代码,可是EAN13太多限制不考虑用.又找到另一个版本的条码输出程序,好像是CODE39.不过打印出来的条码用扫描枪描,没反应.
没办法了,只好自己做了,我看CODE128不错,编码比较简单,我的扫描枪也可以扫出来,就用它了.
有时候编程就是无聊的体力活.我把网上找到的100多个符号代码从表格里一个一个COPY出来,放到一个数组里,就这么简单,我完成了这个CODE128条码生成器.因为我们的订单号只有数字,所以我只加入了数字的编码.而这个条码生成器就只能支持数字了.

<% Dim barcode(106)
barcode(0)="||_||__||__"
barcode(1)="||__||_||__"
barcode(2)="||__||__||_"
barcode(3)="|__|__||___"
barcode(4)="|__|___||__"
barcode(5)="|___|__||__"
barcode(6)="|__||__|___"
barcode(7)="|__||___|__"
barcode(8)="|___||__|__"
barcode(9)="||__|__|___"
barcode(10)="||__|___|__"
barcode(11)="||___|__|__"
barcode(12)="|_||__|||__"
barcode(13)="|__||_|||__"
barcode(14)="|__||__|||_"
barcode(15)="|_|||__||__"
barcode(16)="|__|||_||__"
barcode(17)="|__|||__||_"
barcode(18)="||__|||__|_"
barcode(19)="||__|_|||__"
barcode(20)="||__|__|||_"
barcode(21)="||_|||__|__"
barcode(22)="||__|||_|__"
barcode(23)="|||_||_|||_"
barcode(24)="|||_|__||__"
barcode(25)="|||__|_||__"
barcode(26)="|||__|__||_"
barcode(27)="|||_||__|__"
barcode(28)="|||__||_|__"
barcode(29)="|||__||__|_"
barcode(30)="||_||_||___"
barcode(31)="||_||___||_"
barcode(32)="||___||_||_"
barcode(33)="|_|___||___"
barcode(34)="|___|_||___"
barcode(35)="|___|___||_"
barcode(36)="|_||___|___"
barcode(37)="|___||_|___"
barcode(38)="|___||___|_"
barcode(39)="||_|___|___"
barcode(40)="||___|_|___"
barcode(41)="||___|___|_"
barcode(42)="|_||_|||___"
barcode(43)="|_||___|||_"
barcode(44)="|___||_|||_"
barcode(45)="|_|||_||___"
barcode(46)="|_|||___||_"
barcode(47)="|___|||_||_"
barcode(48)="|||_|||_||_"
barcode(49)="||_|___|||_"
barcode(50)="||___|_|||_"
barcode(51)="||_|||_|___"
barcode(52)="||_|||___|_"
barcode(53)="||_|||_|||_"
barcode(54)="|||_|_||___"
barcode(55)="|||_|___||_"
barcode(56)="|||___|_||_"
barcode(57)="|||_||_|___"
barcode(58)="|||_||___|_"
barcode(59)="|||___||_|_"
barcode(60)="|||_||||_|_"
barcode(61)="||__|____|_"
barcode(62)="||||___|_|_"
barcode(63)="|_|__||____"
barcode(64)="|_|____||__"
barcode(65)="|__|_||____"
barcode(66)="|__|____||_"
barcode(67)="|____|_||__"
barcode(68)="|____|__||_"
barcode(69)="|_||__|____"
barcode(70)="|_||____|__"
barcode(71)="|__||_|____"
barcode(72)="|__||____|_"
barcode(73)="|____||_|__"
barcode(74)="|____||__|_"
barcode(75)="||____|__|_"
barcode(76)="||__|_|____"
barcode(77)="||||_|||_|_"
barcode(78)="||____|_|__"
barcode(79)="|___||||_|_"
barcode(80)="|_|__||||__"
barcode(81)="|__|_||||__"
barcode(82)="|__|__||||_"
barcode(83)="|_||||__|__"
barcode(84)="|__||||_|__"
barcode(85)="|__||||__|_"
barcode(86)="||||_|__|__"
barcode(87)="||||__|_|__"
barcode(88)="||||__|__|_"
barcode(89)="||_||_||||_"
barcode(90)="||_||||_||_"
barcode(91)="||||_||_||_"
barcode(92)="|_|_||||___"
barcode(93)="|_|___||||_"
barcode(94)="|___|_||||_"
barcode(95)="|_||||_|___"
barcode(96)="|_||||___|_"
barcode(97)="||||_|_|___"
barcode(98)="||||_|___|_"
barcode(99)="|_|||_||||_"
barcode(100)="|_||||_|||_"
barcode(101)="|||_|_||||_"
barcode(102)="||||_|_|||_"
barcode(103)="||_|____|__"
barcode(104)="||_|__|____"
barcode(105)="||_|__|||__"
barcode(106)="||___|||_|_"
Dim numcode(9)
numcode(0)="|__|||_||__"
numcode(1)="|__|||__||_"
numcode(2)="||__|||__|_"
numcode(3)="||__|_|||__"
numcode(4)="||__|__|||_"
numcode(5)="||_|||__|__"
numcode(6)="||__|||_|__"
numcode(7)="|||_||_|||_"
numcode(8)="|||_|__||__"
numcode(9)="|||__|_||__"
Dim numid(9)
numid(0)=16
numid(1)=17
numid(2)=18
numid(3)=19
numid(4)=20
numid(5)=21
numid(6)=22
numid(7)=23
numid(8)=24
numid(9)=25
Function gethaxstr(odrid)
s=odrid
Dim t
For i=1 To Len(s)
t=t+(i*numid(Mid(s,i,1)))
Next
t=t+103
t=t Mod 103
gethaxstr=t
End Function
Function hascode(odrid)
tstr=odrid
tstr=Replace(tstr,"0",numcode(0))
tstr=Replace(tstr,"1",numcode(1))
tstr=Replace(tstr,"2",numcode(2))
tstr=Replace(tstr,"3",numcode(3))
tstr=Replace(tstr,"4",numcode(4))
tstr=Replace(tstr,"5",numcode(5))
tstr=Replace(tstr,"6",numcode(6))
tstr=Replace(tstr,"7",numcode(7))
tstr=Replace(tstr,"8",numcode(8))
tstr=Replace(tstr,"9",numcode(9))
tstr="||_|____|__" & tstr & barcode(gethaxstr(odrid)) &"||___|||_|_||"
hascode=tstr
End Function
Function setcolor(odrstr,w)
code_H=50
code_W=w
c = odrstr
c = replace(c,"_","<div style='width:"& code_W &";height:50;float:left;background-color:#ffffff'></div>"& chr(10))
c = replace(c,"|","<div style='width:"& code_W &";height:50;float:left;background-color:#000000'></div>"& chr(10))
setcolor = c
End Function %>
<%=setcolor(hascode("123456"),2)%><br><br><br><br><br><br><br>
<%=setcolor(hascode("9771673173148"),3)%><br><br><br><br><br><br><br><br>

 

转载请注明:HANLEI'BLOG » CODE 128条码生成ASP版