Board logo

标题: VBS版工资管理:金库 [打印本页]

作者: Batcher    时间: 2009-2-27 22:25     标题: VBS版工资管理:金库

  1. dim achoose,anow,income(),outpay(),shuo1(),shuo2()
  2. achoose=msgbox("请选择添加新的还是浏览" & VBcrlf & VBcrlf & "是:添加 否:浏览 ",vbinformation + vbyesno,"选择方式")
  3. if achoose=vbyes then
  4. anow=getdate()
  5. adate=inputdate(anow)
  6. if not adate="" then
  7. atype=msgbox("请选择收入还是支出" & VBcrlf & VBcrlf & "是:收入 否:支出 ",vbyesno)
  8. addnew adate,atype
  9. end if
  10. else
  11. anow=getdate()
  12. adate=inputdate(anow)
  13. if not adate="" then
  14. atype=msgbox("请选择收入还是支出" & VBcrlf & VBcrlf & "是:收入 否:支出 ",vbyesno)
  15. view adate,atype
  16. end if
  17. end if
  18. rem 添加子过程
  19. sub addnew(idate,itype)
  20. path=left(wscript.scriptfullname,len(wscript.scriptfullname)-len(wscript.scriptname))
  21. datefolder="record-" & idate
  22. path=checkfolder(path,datefolder)
  23. if itype=vbyes then
  24. path=path & "收入.txt"
  25. else
  26. path=path & "支出.txt"
  27. end if
  28. set fso=createobject("scripting.filesystemobject")
  29. if not fso.fileexists(path) then
  30. set cfile=fso.createtextfile(path)
  31. cfile.write("金额"& vbtab & vbtab & "备注" & vbcrlf)
  32. cfile.write("--------------------------------" & vbcrlf)
  33. cfile.close
  34. end if
  35. flag1=false
  36. do
  37. ci=inputbox("请输入次数"& vbcrlf & "输入quit取消!","次数")
  38. flag1=checknum(ci)
  39. loop until flag1=true
  40. redim income(ci)
  41. redim shuo1(ci)
  42. for i=0 to ci-1
  43. j=ci-1
  44. flag2=false
  45. do
  46. income(i)=inputbox("请输入收入"& vbcrlf & "输入quit取消!","第" & i+1 & "次")
  47. flag2=checknum(income(i))
  48. loop until flag2=true
  49. shuo1(i)=inputbox("请输入说明","第" & i+1 & "次")
  50. incheck=msgbox("收入是:" & income(i) & vbcrlf & vbcrlf &"说明是:"_
  51. & shuo1(i) & vbcrlf & vbcrlf & "继续么?",vbyesno+vbinformation,"第" & i+1 & "次")
  52. if incheck=vbno then
  53. j=i
  54. exit for
  55. end if
  56. next
  57. set myfile1=fso.opentextfile(path,8,true)
  58. for i=0 to j
  59. myfile1.write(income(i)& vbtab & vbtab & shuo1(i) & vbcrlf)
  60. next
  61. myfile1.write("--------------------------------" & vbcrlf)
  62. msgbox "添加成功!!"
  63. myfile1.close
  64. view idate,itype
  65. end sub
  66. rem 查看记录子过程
  67. sub view(idate,itype)
  68. set fso=createobject("scripting.filesystemobject")
  69. path=left(wscript.scriptfullname,len(wscript.scriptfullname)-len(wscript.scriptname))
  70. if right(path,1)<>"\" then path=path & "\"
  71. datefolder="record-" & idate
  72. tmpdir=split(datefolder,"-")
  73. for i=0 to ubound(tmpdir)
  74. path=path & tmpdir(i) & "\"
  75. next
  76. if itype=vbyes then
  77. path=path & "收入.txt"
  78. else
  79. path=path & "支出.txt"
  80. end if
  81. if not fso.fileexists(path) then
  82. msgbox "没有相关日期记录"
  83. else
  84. set red=fso.opentextfile(path)
  85. txt=red.readall
  86. msgbox txt
  87. red.close
  88. end if
  89. end sub
  90. rem 日期输入
  91. function inputdate(idate)
  92. do
  93. checkdate=inputbox("请输入年月,格式:“1986-3”","输入年月",idate)
  94. if not mid(checkdate,5,1)="-" then
  95. msgbox "输入出错!"
  96. else
  97. inputdate=checkdate
  98. exit do
  99. end if
  100. loop
  101. end function
  102. rem 获取时间
  103. function getdate()
  104. gyear=year(date())
  105. gmonth=month(date())
  106. getdate=gyear & "-" & gmonth
  107. end function
  108. rem 检查输入是否不为数字或为空字符
  109. function checknum(num)
  110. if num="quit" then
  111. wscript.quit
  112. elseif not isnumeric(num) or num=null or num="" then
  113. checknum=false
  114. msgbox "输入错误!",VbCritical + vbOKOnly,"出错啦!!"
  115. else
  116. checknum=true
  117. end if
  118. end function
  119. rem 检查文件夹是否存在
  120. function checkfolder(ipath,idir)
  121. set fso=createobject("scripting.filesystemobject")
  122. if right(ipath,1)<>"\" then ipath=ipath & "\"
  123. tmpdir=split(idir,"-")
  124. for i=0 to ubound(tmpdir)
  125. ipath=ipath & tmpdir(i) & "\"
  126. if not fso.folderexists(ipath) then
  127. fso.createfolder(ipath)
  128. end if
  129. next
  130. checkfolder=ipath
  131. end function
复制代码

作者: defanive    时间: 2009-2-27 22:33

用VBS做,没界面实在累人。。。
HTA可能好点。。。




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2