第2个回答 2012-07-05
'以下代码保存为VBS类型文件
'______________________________________________
'Dim objct
dim Fso,CD,Spl,Read,File,STx,S0R
set fso=createobject("scripting.filesystemobject")
set cd=createobject("useraccounts.commondialog")
'______________________________________________
'Main code
file=showopen("All FILE|*.*|TXT|*.TXT",chr(46))
if len(file)=0 then wscript.quit
filename=mid(file,instrrev(file, chr(92))+1)
do
spl=inputbox("请输入作为分隔符的字符串")
if spl=false then
wscript.quit
else
if len(spl)>0 then exit do
end if
loop
do
stx=inputbox("请输入要截取的内容"&CHR(13)&"[1]*"&spl&CHR(13)&"[2]"&spl&"*")
if stx=false then
wscript.quit
else
if len(stx)>0 then exit do
end if
loop
read=fso.opentextfile(file).readall
for each i in split(read,vbcrlf)
if stx=1 then
s0r=s0r&trim(mid(i,1,instrrev(i,spl)-len(sa)))&chr(13)
else
s0r=s0r&trim(mid(i,instrrev(i, spl)+len(sa)))&chr(13)
end if
next
if right(s0r,1)=chr(13) then s0r=left(s0r,len(s0r)-1)
fso.createtextfile("change_"&filename).write s0r
'______________________________________________
'Function code
public function showopen(byval typeval,byval dirval)
cd.initialdir=dirval
cd.filter=typeval
cd.showopen
showopen=cd.filename
if showopen=vbnullstring then exit function
end function本回答被提问者采纳