• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

生成EAN13标准的条形码的ASP代码实例

asp 搞代码 4年前 (2022-01-03) 38次浏览 已收录 0个评论

代码如下:
条形码生成
<%
Rem =================================================================
Rem = 函数:ean13
Rem = 说明:生成EAN13标准的条形码,有实例(ASP代码)
Rem = 版本:1.0.0
Rem = 作者:第七种直角(7th/semico)
Rem = Date:2005-08-08

来源gaodai.ma#com搞##代!^码网

11:57:06
Rem = QQ:11110785
Rem = QQ群:3773360
Rem = 适用:按照需要生成EAN13标准的条形码
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 ‘条码高度

 ‘检验条码是否符合标准
 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 “必须为数字码!”:response.end
  end if
 next
 if 10-((lsum*3+rsum) mod 10) int(right(code,1)) then response.write “此条码错误!”:response.end

 

 ‘转换条码
 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 “


 ‘绘制条码
 for x=1 to len(barcode)
  if x92 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 “


 next
 ‘加入可读数字标签
 response.write “

“&left(code,1)&”


 for x=1 to 6
  response.write “

“&mid(code,x+1,1)&”


  response.write “

“&mid(code,x+7,1)&”


 next
 response.write “

© 2007 by elbo


 response.write “


End Function

%> 


适用:按照需要生成EAN13标准的条形码

可以试验以下条码:

9787900420206

9787894954947

 
 

<%
if request(“bcode”)”” then
 call ean13(request(“bcode”),2,100)
else
 call ean13(“1234567890128”,2,100)
end if

%>

版权所有

以上就是生成EAN13标准的条形码的ASP代码实例的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:生成EAN13标准的条形码的ASP代码实例

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址