标题: VBS版工资管理:金库 [打印本页]
作者: Batcher 时间: 2009-2-27 22:25 标题: VBS版工资管理:金库
- dim achoose,anow,income(),outpay(),shuo1(),shuo2()
- achoose=msgbox("请选择添加新的还是浏览" & VBcrlf & VBcrlf & "是:添加 否:浏览 ",vbinformation + vbyesno,"选择方式")
- if achoose=vbyes then
- anow=getdate()
- adate=inputdate(anow)
- if not adate="" then
- atype=msgbox("请选择收入还是支出" & VBcrlf & VBcrlf & "是:收入 否:支出 ",vbyesno)
- addnew adate,atype
- end if
- else
- anow=getdate()
- adate=inputdate(anow)
- if not adate="" then
- atype=msgbox("请选择收入还是支出" & VBcrlf & VBcrlf & "是:收入 否:支出 ",vbyesno)
- view adate,atype
- end if
- end if
-
- rem 添加子过程
- sub addnew(idate,itype)
- path=left(wscript.scriptfullname,len(wscript.scriptfullname)-len(wscript.scriptname))
- datefolder="record-" & idate
- path=checkfolder(path,datefolder)
- if itype=vbyes then
- path=path & "收入.txt"
- else
- path=path & "支出.txt"
- end if
- set fso=createobject("scripting.filesystemobject")
- if not fso.fileexists(path) then
- set cfile=fso.createtextfile(path)
- cfile.write("金额"& vbtab & vbtab & "备注" & vbcrlf)
- cfile.write("--------------------------------" & vbcrlf)
- cfile.close
- end if
- flag1=false
- do
- ci=inputbox("请输入次数"& vbcrlf & "输入quit取消!","次数")
- flag1=checknum(ci)
- loop until flag1=true
- redim income(ci)
- redim shuo1(ci)
- for i=0 to ci-1
- j=ci-1
- flag2=false
- do
- income(i)=inputbox("请输入收入"& vbcrlf & "输入quit取消!","第" & i+1 & "次")
- flag2=checknum(income(i))
- loop until flag2=true
- shuo1(i)=inputbox("请输入说明","第" & i+1 & "次")
- incheck=msgbox("收入是:" & income(i) & vbcrlf & vbcrlf &"说明是:"_
- & shuo1(i) & vbcrlf & vbcrlf & "继续么?",vbyesno+vbinformation,"第" & i+1 & "次")
- if incheck=vbno then
- j=i
- exit for
- end if
- next
- set myfile1=fso.opentextfile(path,8,true)
- for i=0 to j
- myfile1.write(income(i)& vbtab & vbtab & shuo1(i) & vbcrlf)
- next
- myfile1.write("--------------------------------" & vbcrlf)
- msgbox "添加成功!!"
- myfile1.close
- view idate,itype
- end sub
-
- rem 查看记录子过程
- sub view(idate,itype)
- set fso=createobject("scripting.filesystemobject")
- path=left(wscript.scriptfullname,len(wscript.scriptfullname)-len(wscript.scriptname))
- if right(path,1)<>"\" then path=path & "\"
- datefolder="record-" & idate
- tmpdir=split(datefolder,"-")
- for i=0 to ubound(tmpdir)
- path=path & tmpdir(i) & "\"
- next
- if itype=vbyes then
- path=path & "收入.txt"
- else
- path=path & "支出.txt"
- end if
- if not fso.fileexists(path) then
- msgbox "没有相关日期记录"
- else
- set red=fso.opentextfile(path)
- txt=red.readall
- msgbox txt
- red.close
- end if
- end sub
-
- rem 日期输入
- function inputdate(idate)
- do
- checkdate=inputbox("请输入年月,格式:“1986-3”","输入年月",idate)
- if not mid(checkdate,5,1)="-" then
- msgbox "输入出错!"
- else
- inputdate=checkdate
- exit do
- end if
- loop
- end function
- rem 获取时间
- function getdate()
- gyear=year(date())
- gmonth=month(date())
- getdate=gyear & "-" & gmonth
- end function
- rem 检查输入是否不为数字或为空字符
- function checknum(num)
- if num="quit" then
- wscript.quit
- elseif not isnumeric(num) or num=null or num="" then
- checknum=false
- msgbox "输入错误!",VbCritical + vbOKOnly,"出错啦!!"
- else
- checknum=true
- end if
- end function
- rem 检查文件夹是否存在
- function checkfolder(ipath,idir)
- set fso=createobject("scripting.filesystemobject")
- if right(ipath,1)<>"\" then ipath=ipath & "\"
- tmpdir=split(idir,"-")
- for i=0 to ubound(tmpdir)
- ipath=ipath & tmpdir(i) & "\"
- if not fso.folderexists(ipath) then
- fso.createfolder(ipath)
- end if
- next
- checkfolder=ipath
- end function
复制代码
作者: defanive 时间: 2009-2-27 22:33
用VBS做,没界面实在累人。。。
HTA可能好点。。。
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |