就是把 sdfs-d-f9-34i-129-df-sf 里面的-替换成空格返回作者: anqing 时间: 2007-2-11 22:31 谢谢,请再帮看看这个代码,尤其是最后部份不太明白?
dim jintian
Set ws=CreateObject("wscript.shell")
Set fso=CreateObject("scripting.filesystemobject")
Set fle=fso.opentextfile(dateadd("d",-6,date) & ".txt")
Do While fle.atendofstream<>true
m=fle.readline
ff=replace(m,glhz(m),"")
s=s & chae(ff,glhz(m)) & vbcrlf
loop
fle.close
Set file=fso.createtextfile(date & ".txt")
file.write jintian
file.close
Set file=fso.createtextfile("今天和昨天的差额.txt")
file.write s
file.close
ws.run "notepad.exe 今天和昨天的差额.txt",,true
msgbox "请查看【" & date & ".txt】文件,看看输入是否正确。",4096+48,"操作完成"
Function chae(xm,je)
do until a=1
sdf=inputbox("请输入【" & xm & "】的金额:",xm)
if sdf="" then
wscript.quit
elseif IsNumeric(sdf)<>true then
msgbox "输入错误,请重新输入。",16+4096,"错误"
else
a=1
end if
loop
if sdf>0 then
chae=xm & sdf-je
end if
jintian=jintian & xm & sdf &vbcrlf
a=0
End Function
Function glhz(zhifu)
a=Len(zhifu)
For i=1 To a
b=Mid(zhifu,i,1)
If IsNumeric(b)=True then
glhz=glhz&Mid(zhifu,i,1)
End if
next
end Function
最后听部分有人曾经讲过是截取字符串的作用。
但这里,m代表一个文本文件。
2007-2-1
水电费:100
合同金:100
外援费:100作者: jmz573515 时间: 2007-2-11 23:09 Function glhz(zhifu) '这是一个自定义函数(声明一个新的函数)
...
end Function作者: anqing 时间: 2007-2-11 23:12 这个我知道,
主要是它的作用?
能否加上注释作者: jmz573515 时间: 2007-2-11 23:17 Function glhz(zhifu) '自定义函数
a=Len(zhifu) '看到上面这一行(ff=replace(m,glhz(m),""))了吗?所以这里的len(zhifu)=len(m)
For i=1 To a
b=Mid(zhifu,i,1) '相当于b=mid(m,i,1)
If IsNumeric(b)=True then '判断b是不是数字
glhz=glhz&Mid(zhifu,i,1)
End if
next
end Function作者: anqing 时间: 2007-2-11 23:37 这些也知道了,
不知道的是:
m是一个txt文件,len是如何在txt取值的,是取出名称,还是数字呀?