[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[原创] VBS版消费记录程序

  1. '///youxi01@bbs.bathome.net;2006
  2. '///刚学vbs所做;
  3. dim wsh
  4. set fso=createobject("scripting.filesystemobject")
  5. '----------------获得星期------------
  6. dim weekdayname
  7. function getweekday()
  8. weekdayname=array("日","一","二","三","四","五","六")
  9. getweekday="星期"&weekdayname(weekday(now())-1)
  10. end function
  11. '==============检查字符长度========
  12. function chkl(num,obj,length)
  13. c=len(obj)      
  14. if num=0 then
  15. if c>length then
  16. wscript.echo "你是来捣乱的吧?!你能赚这么多钱?!"
  17. chkl="err"
  18. else
  19. chkl=obj
  20. end if
  21. else
  22. if c>length then        
  23. chkl=left(obj,length)
  24. else
  25. chkl=obj
  26. end if
  27. end if
  28. end function
  29. '==============对齐==============
  30. function align(num1,obj,num2)
  31. length=len(obj)
  32. for i=1 to length
  33. if flag=<8 then
  34. sstr=mid(obj,i,1)
  35. sstrr=asc(sstr)
  36. if sstrr<0 then
  37. flag=flag+2
  38. else
  39. flag=flag+1
  40. end if
  41. obj1=obj1&sstr
  42. else
  43. exit for
  44. end if
  45. next
  46. length=num2-flag-num1
  47. align=space(num1)&obj1&space(length)
  48. end function           '38
  49. '=============获得文件夹路径=============
  50. function getfd(obj)
  51. set fo=fso.getfile(obj)
  52. getfd=fo.parentfolder
  53. end function
  54. '==========检查是否存在工资表===========
  55. function filees()
  56. parentfd=getfd(wscript.scriptfullname)
  57. if not fso.fileexists(parentfd&"\工资收支明细表.txt") then
  58. wscript.echo "您是第一次运行本程序,正在建立文本文档,请稍后运行..."
  59. set fl=fso.createtextfile(parentfd&"\工资收支明细表.txt")
  60. fl.write align(0,"",30)&vbcrlf                    '28
  61. fl.write align(0,"",20)&"工资收支明细表"&vbcrlf
  62. fl.write "----------------------------------------------------"&vbcrlf
  63. fl.write space(35)&"总的工资收入:0"&vbcrlf
  64. fl.write align(11,"=================",35)&"总的花费:0"&vbcrlf
  65. fl.write align(11,"沉沦天子",35)&vbcrlf
  66. fl.write align(11,"于06-3-23",35)&"金钱理论剩余:0"&vbcrlf
  67. fl.write align(11,"=================",35)&vbcrlf
  68. fl.write align(0,"",35)&"记录开始于2006-3-23日"&vbcrlf
  69. fl.write "----------------------------------------------------"&vbcrlf
  70. fl.write "收支数额"&space(3)&"‖"&align(2,"收支种类",12)&"‖"&align(2,"收支日期",12)&"‖"&align(2,"收支星期",10)&"‖"&vbcrlf
  71. fl.write "----------------------------------------------------"&vbcrlf
  72. fl.close         
  73. else
  74. money=inputbox("请输入金钱的数目!","输入")     
  75. if isnumeric(money)<>-1 then
  76. if ucase(money)="C" then
  77. set wsh=createobject("wscript.shell")
  78. wsh.run parentfd&"\工资收支明细表.txt"
  79. exit function
  80. else
  81. wscript.echo "输入错误,请输入数字!如:"&chr(34)&"1"&chr(34)
  82. exit function
  83. end if
  84. elseif money="" then
  85. exit function
  86. else
  87. money=chkl(0,money,8)
  88. if money="err" then
  89. exit function
  90. else money=int(money)
  91. end if
  92. money=trim(money)
  93. intype=inputbox("请输入收支类型!","输入")
  94. intype=trim(intype)
  95. intype=chkl(1,intype,5)
  96. end if
  97. '--------------------------读取工资文件----------------------
  98. set open=fso.opentextfile(parentfd&"\工资收支明细表.txt",1,1)
  99. for i=1 to 3                  
  100. str=str+open.readline&vbcrlf
  101. next
  102. in_str=open.readline
  103. in_str1=split(in_str,":")
  104. str1=int(in_str1(1))
  105. con_str=open.readline     
  106. con_str1=split(con_str,":")
  107. str2=int(con_str1(1))
  108. str4=open.readline
  109. rem_str=open.readline
  110. rem_str1=split(rem_str,":")
  111. str3=int(rem_str1(1))
  112. if money>0 then
  113. str1=money+str1
  114. str1=in_str1(0)&":"&str1
  115. str3=money+str3
  116. str3=rem_str1(0)&":"&str3
  117. str2=con_str
  118. else
  119. str1=in_str
  120. str2=str2-money
  121. str2=con_str1(0)&":"&str2
  122. str3=money+str3
  123. str3=rem_str1(0)&":"&str3
  124. end if
  125. all=open.readall
  126. all=str&str1&vbcrlf&str2&vbcrlf&str4&vbcrlf&str3&vbcrlf&all
  127. all=all&align(1,money,11)&"‖"&align(2,intype,12)&"‖"&align(2,date(),12)&"‖"&align(2,getweekday(),10)&"‖"&vbcrlf
  128. all=all&"----------------------------------------------------"&vbcrlf
  129. open.close
  130. '==================写文件========================
  131. set wr=fso.opentextfile(parentfd&"\工资收支明细表.txt",2,1)
  132. wr.write all
  133. wr.close
  134. end if
  135. end function
  136. filees
复制代码

EN

不错不错

很实用啊

TOP

有些地方还是看不懂,学习中^_^

TOP

有毒呀,真的吗, 我是大蜘蛛哟

TOP

返回列表