Public Sub FileToFileUpdate(ByVal fileName As String, ByVal strFrm As String, ByVal strTo As String)
Dim newFileName As String
newFileName = fileName & "_bak"
Name fileName As newFileName
Dim vFso As New Scripting.FileSystemObject
Dim vTextStreamR As TextStream
Dim vTextStreamW As TextStream
Set vTextStreamR = vFso.GetFile(newFileName).OpenAsTextStream(ForReading, TristateUseDefault)
Call vFso.CreateTextFile(fileName, True)
Set vTextStreamW = vFso.GetFile(fileName).OpenAsTextStream(ForWriting, TristateUseDefault)
Do Until vTextStreamR.AtEndOfStream
vTextStreamW.WriteLine Replace(vTextStreamR.ReadLine, strFrm, strTo)
Loop
Set vTextStreamR = Nothing
Set vTextStreamW = Nothing
Call vFso.DeleteFile(newFileName)
Set vFso = Nothing
End Sub
人生不断地重复着一次一次的问题,把这些问题记录下来,让自己和有需要的人省点时间。