『第
2 楼』:
DeleteLine "c:\1.txt", 2
InsertLine "c:\1.txt", 2, "*"
Sub DeleteLine(filespec, rownum)
Dim fso, f, temp, i
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(filespec, 1)
temp = ""
i = 0
While Not f.AtEndOfStream
i = i + 1
If Not i = rownum Then
temp = temp & f.ReadLine & vbCrLf
Else
f.SkipLine
End If
WEnd
f.Close
Set f = fso.OpenTextFile(filespec, 2)
f.Write temp
f.Close
End Sub
Sub InsertLine(filespec, rownum, oneline)
Dim fso, f, temp, i
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(filespec, 1)
temp = ""
i = 0
While Not f.AtEndOfStream
i = i + 1
If i = rownum Then temp = temp & oneline & vbCrLf
temp = temp & f.ReadLine & vbCrLf
WEnd
f.Close
Set f = fso.OpenTextFile(filespec, 2)
f.Write temp
f.Close
End Sub
|