hta编写的消费记录程序

2023-12-05 0 907

将代码复制粘贴到一文本文档中,然后保存,并将该文件后缀名改为:hta,双击即可运行。复制代码 代码如下:<!–////////程序说明/////////==== 程序名称:消费记录Ver1.1(20070808-20070811).hta 使用说明:将代码复制粘贴到一文本文档中,然后保存,并将该文件后缀名改为:hta,双击即可运行。 作者说明:youxi01,,,版权没有,欢迎盗版!!///////////–> <!–///////设置题头,编码方式//////–> <TITLE>消费记录程序</TITLE> <meta http-equiv=\”Content-Type\” content=\”text/html; charset=gb2312\”/> <!–///////hta标志//////–> <HTA:APPLICATION SCROLL=\”no\” CAPTION=\”yes\” SYSMENU=\”yes\”/> <!–///////控制程序部分//////–> <script language=\”vbscript\”> totalMoney=0 \’总消费额 index=-1 \’初始化checkbox控件ID序号; flag=0 \’定义文件是否改动的标志 set fso=createobject(\”scripting.filesystemobject\”) \’///////////////////文件载入时,读取配置文件,定义自身大小、位置//////// Sub Window_onLoad if not (fso.fileexists(\”consume.ini\”)) then \’不存在配置文件则创建; fso.createtextfile(\”consume.ini\”).close end if window.resizeTo 638,495 \’设置自身大小、位置; window.moveTo 200,100 addRow 0,\”hoho\”,\”2007-1-1\”,\”星期二\” \’先添加一个行。自己都搞不明白,反正用来处理bug; document.all.namedItem(\”mytable\”).rows(1).style.display=\”none\” \’设置这行不可见; addRow 0,\”hoho\”,\”2007-1-1\”,\”星期二\” \’再添加一个行。自己都搞不明白,反正用来处理bug; document.all.namedItem(\”mytable\”).rows(2).style.display=\”none\” \’设置这行不可见; readFile(\”consume.ini\”) End Sub \’//////////////////读取文件////////////////// Function readFile(filename) set file=fso.opentextfile(filename,1,1) do while file.atendofline<>true \’读文件一直到文件尾部 str=split(file.readline,\”#\”) \’按#标志分割没行(总共有四个这种标志) addRow str(1),str(2),str(3),str(4) \’添加五个单元格,内容分别为…. loop End Function \’////////////////添加表行,单元格/////////// Function addRow(cnum,ctype,cdate,cday) index=index+1 \’序号自加1 set objTable=document.all.namedItem(\”mytable\”) \’根据ID获取对象表格 set newrow = objTable.insertRow() \’插入一行 newrow.className=\”row_add\” \’设置该行的样式; newrow.onmouseover=getRef(\”change_bgcolor\”) newrow.onmouseout=getRef(\”back_bgcolor\”) newrow.onclick=getRef(\”chooseOBJ\”) var=\”#\”&cnum&\”#\”&ctype&\”#\”&cdate&\”#\”&cday str=split(var,\”#\”) str(0)=\”<input type=checkbox id=\’delcheck\’&index>\” for i=0 to 4 set newcell=newrow.insertCell() \’插入单元格,并设置单元格的值; newcell.innerhtml=str(i) next totalMoney=totalMoney+clng(cnum) \’设置总消费额的值,并定义显示; consume.innerHTML=\”消费总额:\”&totalMoney&\”元\” End Function \’///////////////改变对象背景////////////// Function change_bgcolor() me.className=\”new_row_add\” End Function \’/////////////返回原来背景色////////////// Function back_bgcolor() me.className=\”row_add\” End Function \’////////////选定该行///////// Function chooseOBJ() if me.cells(0).children(0).checked=true then me.cells(0).children(0).checked=false else me.cells(0).children(0).checked=true end if End Function \’/////////////////\”删除\”一个单元格/////////////// Function delRow() for i=0 to index if delcheck(i).checked=true then set tag=delcheck(i).parentelement.parentelement \’设置该checkbox所在的行; tag.style.display=\”none\” \’其实,所谓的删除就是把它设置为不显示; totalMoney=totalMoney-clng(tag.cells(1).innertext) consume.innerHTML=\”消费总额:\”&totalMoney&\”元\” tag.cells(1).innertext=\”0\” \’消费额设置为0; end if next flag=1 \’如果执行了删除操作,则标志文件已经改动; End Function \’////////////////////检查输入数据是否正确//////////// Function check(value) if not (isnumeric(value)) then msgbox \”请在消费金额栏中输入数字!\”,64,\”特别提示\” elseif value<1 then msgbox \”你的钱难道越花越多?\”,64,\”特别提示\” else flag=1 addRow money.value,cstype.options(cstype.selectedIndex).innerText,date,weekdayname(weekday(date)) csmonth.selectedIndex = month(date()) \’月份checkbox转到当前月份; selectChange(monthname(month(date()))) \’表格显示为当前月份的数据; end if money.select() \’money输入框选定; End Function \’////////////////////////如果月份checkbox变化////////////// Function selectChange(choose) \’78行; totalMoney=0 for i=0 to index set tag=delcheck(i).parentelement.parentelement mName=monthname(month(tag.cells(3).innertext)) \’获取数据的月份; if trim(choose)=\”一年\” and tag.cells(1).innertext<>\”0\” then tag.style.display=\”\” totalMoney=totalMoney+clng(tag.cells(1).innertext) elseif mName<>trim(choose) or tag.cells(1).innertext=\”0\” then tag.style.display=\”none\” else tag.style.display=\”\” totalMoney=totalMoney+clng(tag.cells(1).innertext) end if next consume.innerHTML=\”消费总额:\”&totalMoney&\”元\” End Function \’////////////全选或全不选按钮控制代码////// Function selectAll() \’96行; if mybutton.value=\”全部选择\” then for i=0 to index delcheck(i).checked=true next mybutton.value=\”全不选择\” else for i=0 to index delcheck(i).checked=false next mybutton.value=\”全部选择\” end if End Function \’/////////////当程序退出时////////////////// Sub Window_onunLoad() if flag=1 then \’文件如果已经标志了改动,则提示是否保存; msg=msgbox(\”提示:你的设置已经更改,是否保存?\”,vbyesno+vbExclamation,\”保存提醒\”) if msg=6 then \’如果选择了“是”; selectChange(\”一年\”) \’当前表格显示的数据为全年的数据; for i=0 to index set tag=delcheck(i).parentelement.parentelement if tag.cells(1).innertext<>\”0\” then txt=txt&\”#\”&tag.cells(1).innertext&\”#\”&tag.cells(2).innertext&\”#\” txt=txt&tag.cells(3).innertext&\”#\”&tag.cells(4).innertext & vbcrlf end if next set file=fso.opentextfile(\”consume.ini\”,2,1) \’覆盖写入文件; file.write(txt).close end if end if End Sub </script> <!–///////以上为控制代码,以下为样式代码/////////////–> <style> #all{border:1px solid #000069;width:600px;text-align:center;padding:2px;} #header{width:598px;text-align:center;font-family: \”隶书\”;font-size: 24px; font-weight: bold;background: #EEE;margin:1px;} #header1{text-align:center;font-size: 16px;width:595px;padding:2px 2px;} #month{float:left;width:20px;margin-left:90px;} #consume{float:left;width:200px;color:red} #main{width:600px;height:300px;background: #EEE;border:1px solid #000069;overflow:auto;} #contain{width:600px;height:30px;border:1px solid #000069;} .line{border:1px solid #000060; height: 1;width:602px;} .line2{border:1px solid white; height: 1;width:600px;} .c_button{text-align:center;float:left;width:100px;border:1px solid #ccc; background-color:#F3F3F3;font-size:12px;color:#333333; padding:5px 2px;margin:2px;line-height:20px;} .c_other{text-align:center;float:left;width:136px; border:1px solid #ccc;background-color:#F3F3F3;font-size:12px;color:#333333; padding:5px 2px;margin:2px;line-height:20px;height:23px; } .button {padding:1px;text-align:center;border:0;background-color:#eee;height:23px;cursor:pointer} .th{text-align=center;background-color:#006699;font-size:14px; font-family: \”隶书\”;color:#F2F3F7;padding:2px;line-height:22px;} .row_add{text-align:center;background-color:#ccd2de;height:4px;font-size:12px;line-height:15px; padding:2px;} .new_row_add{text-align:center;color:red;background-color:#ccd2ad;height:4px; font-size:12px; line-height:15px;padding:2px;cursor:hand;} </style> <!–///////以下为要显示对象/////////////–> <hr class=\”line\”> <div ID=\”all\”> <div id=\”header\”>2007年消费一览表</div> <div id=\”header1\”> <div id=\”month\”><select id=\”csmonth\” onchange=selectChange(csmonth.options(csmonth.selectedIndex).innerText)><option>一年</option><option>一月</option><option>二月</option><option>三月</option><option>四月</option><option>五月</option><option>六月</option><option>七月</option><option>八月</option><option>九月</option><option>十月</option><option>十一月</option><option>十二月</option></select></div> <div id=\”consume\”>消费总额:</div></div> <div id=\”main\”> <table border=0 width=100% ID=\”mytable\”> <tr class=\”th\”><th>选定</th><th>消费金额</th><th>消费类型</th><th>消费日期</th><th>消费星期</th> </table></div> <hr class=\”line2\” color=white> <div id=\”contain\”> <div class=\”c_button\”><input type=submit value=\”全部选择\” class=\”button\” ID=\”mybutton\” onclick=selectAll></div> <div class=\”c_other\”>消费金额:<input type=text name=\”money\” size=5 onmouseover=\’money.select()\’></div> <div class=\”c_other\”>消费类型:<select ID=\”cstype\”><option>饮食</option><option>娱乐</option><option>其它</option></select></div> <div class=\”c_button\”><input type=submit value=\”添加记录\” class=\”button\” onclick=check(money.value)></div><div class=\”c_button\”><input type=submit value=\”删除记录\” class=\”button\” onclick=delRow()></div> </div></div>

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

悠久资源 hta hta编写的消费记录程序 https://www.u-9.cn/jiaoben/hta/99651.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务