求一批处理,或VBs 有两个文件 a.txt 和b.txt 复制a.txt中的内容到b.txt文件的第8行 如:a.txt中内容为

b.TXT内容为 xxxxxxxxxx
要的结果是
1
2
3
4
5
6
7
xxxxxxxxxx
8
9
10
11
最好不要新建文件,就在原文件插入

dim read1,read2,file1,file2
file1="a.txt" 'a.txt
file2="b.txt" 'b.txt,注意引号不能去掉,
set shell=createobject("wscript.shell")
set open=createobject("scripting.filesystemobject")
public function written(byval text,byval writt,byval line,byval col)
for each i in split(text,vbcrlf)
j=j+1
if j=line then
if col=-1 then written=written&left(i,len(i))&writt&vbcrlf else written=written&mid(i,1,col)&writt&mid(i,col+1,len(i))&vbcrlf
else
written=written&i&vbcrlf
end if
next
written=trimt(written)
end function
Public Function TrimT(ByVal Text)
If Right(Text, 2) = vbcrlf Then TrimT = Left(Text, Len(Text) - 2)
End Function
read1=open.opentextfile(file2).readall
read2=open.opentextfile(file1).readall
open.createtextfile(file2).write written(read1,read2,8,-1)
'保存为vbs类型文件
'-----------
'已修改追问

最好不要新建文件,就在源文件修改

追答

没有新建文件修改的就是B.txt 你自己好好检查一下?

追问

新建了new,txt
b,txt内容没改变。
谢谢
请指点

追答

我无语了 我刚修改了代码 你难道没有复制吗?
open.createtextfile(file2).write written(read1,read2,8,-1)
我把"new.txt" 修改为file2了
你脑袋秀逗了?

追问

不好意思,秀逗了一下,那能不能把第8行往下移,
不要改变第8行

温馨提示:答案为网友推荐,仅供参考
相似回答
大家正在搜