生成EAN13標(biāo)準(zhǔn)的條形碼的ASP代碼實(shí)例
<title>條形碼生成</title>
<%
Rem =================================================================
Rem = 函數(shù):ean13
Rem = 說(shuō)明:生成EAN13標(biāo)準(zhǔn)的條形碼,有實(shí)例(ASP代碼)
Rem = 版本:1.0.0
Rem = 作者:第七種直角(7th/semico)
Rem = Date:2005-08-08 11:57:06
Rem = QQ:11110785
Rem = QQ群:3773360
Rem = 適用:按照需要生成EAN13標(biāo)準(zhǔn)的條形碼
Rem =================================================================
Function ean13(code,w,h)
Dim Guide,Dict,Lencode,Rencode,cStart,cMid,cEnd,Barcode,Lmethod
Guide = array("AAAAAA","AABABB","AABBAB","ABAABB","ABBAAB","ABBBAA","ABABAB","ABABBA","ABBABA")
Set Dict = CreateObject("Scripting.Dictionary")
Dict.Add "A", "0001101001100100100110111101010001101100010101111011101101101110001011"
Dict.Add "B", "0100111011001100110110100001001110101110010000101001000100010010010111"
Rencode = array("1110010","1100110","1101100","1000010","1011100","1001110","1010000","1000100","1001000","1110100")
cStart="101"
cMid="01010"
cEnd="101"
if w<2 then w=2
if h<20 then h=20
cWidth=w '條碼單元寬度
cHeight=h '條碼高度
'檢驗(yàn)條碼是否符合標(biāo)準(zhǔn)
if len(code)<>13 then response.write "必須為13位!":response.end
for i=1 to 12
if IsNumeric(mid(code,i,1)) then
if i mod 2 then
rsum=rsum+int(mid(code,i,1))
else
lsum=lsum+int(mid(code,i,1))
end if
else
response.write "必須為數(shù)字碼!":response.end
end if
next
if 10-((lsum*3+rsum) mod 10) <> int(right(code,1)) then response.write "此條碼錯(cuò)誤!":response.end
'轉(zhuǎn)換條碼
Barcode=cStart
Lmethod=left(code,1)
'if Lmethod=0 then Lmethod=1
for i=2 to 7
barcode = barcode & mid(Dict(Mid(Guide(Lmethod-1),i-1,1)),(7*mid(code,i,1)+1),7)
next
barcode=barcode & cMid
for i=8 to 13
barcode = barcode & Rencode(mid(code,i,1))
next
barcode=barcode & cEnd
fg="#000000" '條碼前景色
bg="#ffffff" '條碼背景色
response.write "<div style='position:absolute;width:"&cWidth*95+60&"px; height:"&cHeight+30&"px; background:"&bg&";'>"
'繪制條碼
for x=1 to len(barcode)
if x<5 or x>92 or (x>46 and x<51)then
sh=10
else
sh=0
end if
if mid(barcode,x,1)="1" then
bColor=fg
else
bColor=bg
end if
response.write "<div style='position:absolute;left:"&(x-1)*cWidth+30&"px;top:5px;width:"&cWidth&"px;height:"&cHeight+5+sh&"px;background:"&bColor&";'></div>"
next
'加入可讀數(shù)字標(biāo)簽
response.write "<div style='position:absolute;left:16px;top:"&cHeight+10&"px;background:"&bg&";color:"&fg&";font:12px Verdana;'>"&left(code,1)&"</div>"
for x=1 to 6
response.write "<div style='position:absolute;left:"&(x*7+2)*cWidth+22&"px;top:"&cHeight+10&"px;background:"&bg&";color:"&fg&";font:12px Verdana;'>"&mid(code,x+1,1)&"</div>"
response.write "<div style='position:absolute;left:"&(x*7+47)*cWidth+24&"px;top:"&cHeight+10&"px;background:"&bg&";color:"&fg&";font:12px Verdana;'>"&mid(code,x+7,1)&"</div>"
next
response.write "<div style='position:absolute; left:30px;top:"&cHeight+25&"px;width:"&cWidth*95&"px;height:10px;text-align:center;background:#ffffff;border:solid 1px #e5e5e5;font:9px verdana;'>© 2007 by elbo </div>"
response.write "</div>"
End Function
%>
<p style="font:12px Verdana">
<span style="text-decoration: none">
<font color="#000000">適用:按照需要生成EAN13標(biāo)準(zhǔn)的條形碼</font></span><br />
可以試驗(yàn)以下條碼:<br />
9787900420206<br />
9787894954947
</p>
<br />
<form method="post" action="ttt.asp">
<label>
<input type="" name="bcode" />
</label>
<input type="submit" value="生成條碼"/>
</form>
<p align="center"></p>
<p align="center">
<%
if request("bcode")<>"" then
call ean13(request("bcode"),2,100)
else
call ean13("1234567890128",2,100)
end if
%>
</br></a>版權(quán)所有 </p>
相關(guān)文章
asp OpenTextFile文本讀取與寫(xiě)入實(shí)例代碼
打開(kāi)指定的文件并返回一個(gè) TextStream 對(duì)象,可以讀取、寫(xiě)入此對(duì)象或?qū)⑵渥芳拥轿募?2008-08-08
VBScript ASP CDbl() 函數(shù)轉(zhuǎn)換為雙精度類(lèi)型
CDbl 函數(shù)用于進(jìn)行從其他數(shù)據(jù)類(lèi)型到 Double 子類(lèi)型的國(guó)際公認(rèn)的格式轉(zhuǎn)換。例如,十進(jìn)制分隔符和千位分隔符的識(shí)別取決于系統(tǒng)的區(qū)域設(shè)置。2011-05-05
ASP是使用正則提取內(nèi)容里所有圖片路徑SRC的實(shí)現(xiàn)代碼
有時(shí)候客戶提交的內(nèi)容里包含多個(gè)圖片,客戶想單獨(dú)把圖片路徑提取出來(lái)進(jìn)行保存,下面腳本之家小編跟大家分享ASP正則提取內(nèi)容里所有圖片路徑SRC的方法函數(shù),需要的朋友可以參考下2019-09-09
asp實(shí)現(xiàn)限制搜索的關(guān)鍵字的函數(shù)
asp實(shí)現(xiàn)限制搜索的關(guān)鍵字的函數(shù)...2007-08-08

