金桥科普  
设为首页 关于我们 邮箱登录
科普聚焦时代科技科普生活科学技术自然科学航空航天科技博览历史考古电脑IT
您现在的位置: 首页 >> 科普频道 >> 技巧实践 >> 文章详情
ASP 计数器(使用GrapShot组件)之二

飞刀/aspcn PConline 2002-04-29
给这个目录中放一些能被10整除的数字图形. 

< table width="100%" border="1" cellspacing="1" cellpadding="2" >
< tr >
< td bgcolor="#ccffff" >File < b >counter.asp< /b > < /td >
< /tr >
< tr >
< td bgcolor="#ffffcc" >< pre >
< %
Response.ContentType="image/gif"
Response.Expires=0
'The directory where GIF bars are placed. Ends with 
workdir="c:gifbars"
'Set this to False if you want to disable auto inserting
'new counter records to database on every hit with unique
'id string
auto_insert=True
id=Trim(Request.QueryString("id"))
seq=Trim(Request.QueryString("seq"))
if seq="" then seq="default"
cells=Trim(Request.QueryString("cells"))
if cells="" then cells=5 else cells=cells*1
set conn=Server.CreateObject("ADODB.Connection")
conn.Open "Webcounter"
sql="select count,ident from main where id='" & id & "'"
set rs=conn.Execute(sql)
if not rs.EOF then
count=rs("count")+1
ident=rs("ident")
rs.close()
conn.Execute("update main set count=count+1 where ident=" & ident)
conn.close()
ShowNumbers()
else 
rs.close()
if auto_insert=True and id< >"" then
conn.Execute("insert into main (id,count) values ('" & id & "',1)")
count=1
ShowNumbers()
end if
conn.close()
end if

Sub ShowNumbers()
set g=CreateObject("shotgraph.image")
filename=workdir & seq & ".gif"
if g.GetFileDimensions(filename,xsize,ysize,pal)< >1 then Exit Sub
xdigit=xsize10
g.CreateImage xdigit*cells,ysize,UBound(pal)+1
g.InitClipboard xsize,ysize
g.SelectClipboard True
for i=0 to UBound(pal)
g.SetColor i,pal(i,0),pal(i,1),pal(i,2)
next
g.ReadImage filename,pal,0,0
for i=1 to cells
k=GetDigit(count,cells-i)
g.Copy (i-1)*xdigit,0,xdigit,ysize,k*xdigit,0,"SRCCOPY"
next
Response.BinaryWrite g.GifImage(-1,1,"")
End Sub

Function GetDigit(number,position)
number1=number(10^position)
tmp=number110
GetDigit=number1-tmp*10
End Function

% >
< xmp >
< /pre >
< /td >
< /tr >
< /table >

< hr >< /span >< /td >
< /tr >
< tr >
< td width="50%" > < /td >
< td width="50%" >< br >< /td >
< /tr >
< tr >
< td colspan=2 align="right" >
< img border="0" src="images/bbstitle.gif" >< a id="hlkAddMsg" href="/AddMsg.aspx?id=234" style="color:red" >发表评论< /a >
< img border="0" src="images/mail.gif" >< a id="hlkMailTo" href="/MailTo.aspx?id=234" >邮寄本页< /a >
< img border="0" src="images/print.gif" >< a href="javascript:window.print()" >打印本页< /a >
< img border="0" src="images/profile.gif" >< a href="javascript:void(null)" onclick="if(!document.execCommand('SaveAs','show.aspx',1)) return false;" >保存本页< /a >
< img border="0" src="images/ask.gif" >< a href="bbs/index.asp" >您有疑问< /a >
< /td >
< /tr >
< tr bgcolor="#97B9FF" >
< td width="50%" >< b >< font color="#FFFFFF" >相关文章< /font >< /b >< /td >
< td width="50%" >< b >< font color="#FFFFFF" >相关评论< /font >< /b >< /td >
< /tr >
< tr >
< td width="50%" valign="top" >


< /td >
< td width="50%" valign="top" >

< /td >
< /tr >
< tr >
< td width="50%" >
< /td >
< td width="50%" align="right" >< img border="0" src="images/more.gif" >< a id="hlkRela" >< /a >< /td >
< /tr >
< /table >
< /td >
< /tr >
< /table >
< /td >
< /tr >
< /table >
< /body >
< /html >

  发表评论 写信给编辑 关闭窗口
同栏目内容
· 让你的电脑启动画面绚起来 2007-09-12
· 小技巧帮大忙 极点五笔 2007-09-05
· 如何提高迅雷的下载速度? 2007-09-03
· Vista小技巧 消除红眼 2007-09-03
· 千千静听实用小功能 2007-08-29
· Windows 自动登陆的简单方法 2007-08-20
相关内容
近期主推
西藏发现青藏高原最大冰川群
·西藏发现青藏高原最大冰川群
·中日: "月亮女神"携手"嫦娥"
·行星大碰撞砸死恐龙催生人类
·美研制会飞汽车定价9万美元
·美国教授设计出自适应机器人
·银河系可能有20多个黑洞
近期热门
英海域惊现大龙虾为普通龙虾5倍
·英海域惊现大龙虾为普通龙虾5倍
·新物种金蛙体表有剧毒
·我国嫦娥工程计划测量月球
·精神病药物可治多种癌症
·视觉震撼:来自海底的精灵
·能删除不良记忆的药物诞生
近期焦点
广西发现罕见溶洞钟乳石有30万年
·广西发现罕见溶洞钟乳石有30万年
·澳大利亚惊现“卡布基诺”海滩
·美国"彩色"瀑布夜幕下震撼游人
·地球上究竟有多少个物种
·英国探险家北极游泳破纪录
·世界之最 世上最小的动物
金桥科普是一个公益性栏目,内容由作者提供或摘自互联网,其目的是向广大网民普及科学技术知识。如果您发现本网站转载或摘编了您拥有著作权的作品,请通知我们(电话:023-63659911),我们立即删除。
关于我们 | 网站地图 | 用户注册 | 广告客户 | 招聘信息 | 业务信息
Copyright@2006-2009 JQInfo.com,WONDER. All Rights Reserved
重庆科技咨询中心.重庆网得信息技术有限公司.版权所有
Email:webmaster@jqinfo.com
重庆数据通信局提供网络带宽. 渝ICP备05002327号