一个用asp生成条形码的例子代码。(注意:生成的图形为html代码,而非图片,打印时,请在IE的Internet选项=>高级=》打印 选定“打印背景颜色和图像”)
=================================================
1<html>
2<head>
3<meta charset="utf-8" content='\"text/html;' http-equiv='\"Content-Type\"'/>
4<meta content='\"51windows.Net\"' name='\"Keywords\"'/>
5<meta content='\"haiwa\"' name='\"Author\"'/>
6<title>Asp生成条形码</title>
7<style>
8<!--
9* {font:menu}
10\-->
11</style>
12</head>
13<body>
'条形码生成程序
'海娃@2004-4-4
'http://www.51windows.Net
function haiwaocde(zfstr)
zf = zfstr
zf = replace(zf,"0","|||||||")
zf = replace(zf,"1","|||||||")
zf = replace(zf,"2","|||||||")
zf = replace(zf,"3","|||||||")
zf = replace(zf,"4","|||||||")
zf = replace(zf,"5","|||||||")
zf = replace(zf,"7","|||||||")
zf = replace(zf,"6","|||||||")
zf = replace(zf,"8","|||||||")
zf = replace(zf,"9","|||||||")
zf = replace(zf,"a","||||__|||")
zf = replace(zf,"b","||||__|||")
zf = replace(zf,"c","|||||__||")
zf = replace(zf,"d","||||__|||")
zf = replace(zf,"e","|||||__||")
zf = replace(zf,"f","|||||__||")
zf = replace(zf,"g","|||__||||")
zf = replace(zf,"h","||||__|||")
zf = replace(zf,"i","||||__|||")
zf = replace(zf,"j","||||__|||")
zf = replace(zf,"k","|||||||")
zf = replace(zf,"l","|||||||")
zf = replace(zf,"m","|||||||")
zf = replace(zf,"n","|||||||")
zf = replace(zf,"o","|||||||")
zf = replace(zf,"p","|||||||")
zf = replace(zf,"r","|||||||")
zf = replace(zf,"q","|||||||")
zf = replace(zf,"s","|||||||")
zf = replace(zf,"t","|||||||")
zf = replace(zf,"u","||__|||||")
zf = replace(zf,"v","|__||||||")
zf = replace(zf,"w","||__|||||")
zf = replace(zf,"x","|__||||||")
zf = replace(zf,"y","||__|||||")
zf = replace(zf,"z","|__||||||")
zf = replace(zf,"-","|__||||||")
zf = replace(zf,"*","|__||||||")
zf = replace(zf,"/","|||||")
zf = replace(zf,"%","|||||")
zf = replace(zf,"+","|__||||")
zf = replace(zf,".","||__|||||")
haiwaocde = zf
end function
code_H = 52
code_W = 2
function dragcode(ccode)
c = ccode
c = replace(c,"_","<span style="'height:&quot;&code_H&&quot;;width:&quot;&code_w&&quot;;background:#FFFFFF'"></span>")
c = replace(c,"|","<span style="'height:&quot;&code_H&&quot;;width:&quot;&code_w&&quot;;background:#000000'"></span>")
dragcode = c
end function
function dragtext(ccode)
c = ccode
dragtext = ""
for i=1 to len(c)
dragtext = dragtext&"<span style="'width:26;text-align:center'">"∣(c,i,1)&"</span>"
next
dragtext = dragtext
end function
Function CheckExp(patrn,str)
Set regEx=New RegExp
regEx.Pattern=patrn
regEx.IgnoreCase=true
regEx.Global=True
CheckExp = regEx.test(str)
End Function
code = request("c")
if code = "" then
code = "51windows.net"
else
if Checkexp("^[abcdefghijklmnopqrstuvwxyz1234567890\\+\\-\\\/\%\$\\.]$",code) then
code = ""&code&""
else
code = "51windows.net"
errstr = "<br/><center style="'color:red;'">含有非法字符 </center>"
end if
end if
ocode = code
code = lcase(code)
1<center><form method='\"post\"' name='\"form1\"'>合法字符:ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890 + - * / % $ .<br/><br/><input =request(\"c\")="" ```\"="" maxlength='\"15\"' name='\"c\"' size='\"25\"' type='\"text\"' value='\"```'/> <input name='\"Submit\"' type='\"submit\"' value='\"提交\"'/></form><center>
2<div align='\"center\"'>
3<center>
4<table border='\"0\"' cellpadding='\"0\"' cellspacing='\"0\"' height='\"79\"'>
5<tr>
6<td align='\"center\"' height='\"61\"'>```
7=dragcode(haiwaocde(code))
8```</td>
9</tr>
10<tr>
11<td align='\"center\"' height='\"18\"' style='\"text-align:justify;text-justify:Distribute-all-lines;\"'>```
12=(ocode)
13```</td>
14</tr>
15</table>
16</center>
17</div>
=errstr
1</center></center></body>
2</html>