- '///youxi01@bbs.bathome.net;2006
- '///刚学vbs所做;
- dim wsh
- set fso=createobject("scripting.filesystemobject")
- '----------------获得星期------------
- dim weekdayname
- function getweekday()
- weekdayname=array("日","一","二","三","四","五","六")
- getweekday="星期"&weekdayname(weekday(now())-1)
- end function
- '==============检查字符长度========
- function chkl(num,obj,length)
- c=len(obj)
- if num=0 then
- if c>length then
- wscript.echo "你是来捣乱的吧?!你能赚这么多钱?!"
- chkl="err"
- else
- chkl=obj
- end if
- else
- if c>length then
- chkl=left(obj,length)
- else
- chkl=obj
- end if
- end if
- end function
- '==============对齐==============
- function align(num1,obj,num2)
- length=len(obj)
- for i=1 to length
- if flag=<8 then
- sstr=mid(obj,i,1)
- sstrr=asc(sstr)
- if sstrr<0 then
- flag=flag+2
- else
- flag=flag+1
- end if
- obj1=obj1&sstr
- else
- exit for
- end if
- next
- length=num2-flag-num1
- align=space(num1)&obj1&space(length)
- end function '38
-
- '=============获得文件夹路径=============
- function getfd(obj)
- set fo=fso.getfile(obj)
- getfd=fo.parentfolder
- end function
-
- '==========检查是否存在工资表===========
- function filees()
- parentfd=getfd(wscript.scriptfullname)
- if not fso.fileexists(parentfd&"\工资收支明细表.txt") then
- wscript.echo "您是第一次运行本程序,正在建立文本文档,请稍后运行..."
- set fl=fso.createtextfile(parentfd&"\工资收支明细表.txt")
- fl.write align(0,"",30)&vbcrlf '28
- fl.write align(0,"",20)&"工资收支明细表"&vbcrlf
- fl.write "----------------------------------------------------"&vbcrlf
- fl.write space(35)&"总的工资收入:0"&vbcrlf
- fl.write align(11,"=================",35)&"总的花费:0"&vbcrlf
- fl.write align(11,"沉沦天子",35)&vbcrlf
- fl.write align(11,"于06-3-23",35)&"金钱理论剩余:0"&vbcrlf
- fl.write align(11,"=================",35)&vbcrlf
- fl.write align(0,"",35)&"记录开始于2006-3-23日"&vbcrlf
- fl.write "----------------------------------------------------"&vbcrlf
- fl.write "收支数额"&space(3)&"‖"&align(2,"收支种类",12)&"‖"&align(2,"收支日期",12)&"‖"&align(2,"收支星期",10)&"‖"&vbcrlf
- fl.write "----------------------------------------------------"&vbcrlf
- fl.close
- else
- money=inputbox("请输入金钱的数目!","输入")
- if isnumeric(money)<>-1 then
-
- if ucase(money)="C" then
- set wsh=createobject("wscript.shell")
- wsh.run parentfd&"\工资收支明细表.txt"
- exit function
- else
- wscript.echo "输入错误,请输入数字!如:"&chr(34)&"1"&chr(34)
- exit function
- end if
-
- elseif money="" then
- exit function
-
- else
- money=chkl(0,money,8)
- if money="err" then
- exit function
- else money=int(money)
- end if
-
- money=trim(money)
- intype=inputbox("请输入收支类型!","输入")
- intype=trim(intype)
- intype=chkl(1,intype,5)
- end if
- '--------------------------读取工资文件----------------------
- set open=fso.opentextfile(parentfd&"\工资收支明细表.txt",1,1)
- for i=1 to 3
- str=str+open.readline&vbcrlf
- next
- in_str=open.readline
- in_str1=split(in_str,":")
- str1=int(in_str1(1))
-
- con_str=open.readline
- con_str1=split(con_str,":")
- str2=int(con_str1(1))
-
- str4=open.readline
- rem_str=open.readline
- rem_str1=split(rem_str,":")
- str3=int(rem_str1(1))
-
- if money>0 then
- str1=money+str1
- str1=in_str1(0)&":"&str1
- str3=money+str3
- str3=rem_str1(0)&":"&str3
- str2=con_str
- else
- str1=in_str
- str2=str2-money
- str2=con_str1(0)&":"&str2
- str3=money+str3
- str3=rem_str1(0)&":"&str3
- end if
-
- all=open.readall
- all=str&str1&vbcrlf&str2&vbcrlf&str4&vbcrlf&str3&vbcrlf&all
- all=all&align(1,money,11)&"‖"&align(2,intype,12)&"‖"&align(2,date(),12)&"‖"&align(2,getweekday(),10)&"‖"&vbcrlf
- all=all&"----------------------------------------------------"&vbcrlf
- open.close
- '==================写文件========================
- set wr=fso.opentextfile(parentfd&"\工资收支明细表.txt",2,1)
- wr.write all
- wr.close
- end if
- end function
- filees
复制代码
|