文本替换
想替换文本某一行 怎么老从已经有的内容后加,不是替换,请指点Sub tihuan(strTargetFile As String, intRow As Long)
Dim filenum As Integer
Dim fileContents As String
Dim fileInfo() As String
Dim i As Integer
filenum = FreeFile
Open strTargetFile For Binary As #filenum
fileContents = Space(LOF(filenum))
Get #filenum, , fileContents
Close filenum
fileInfo = Split(fileContents, vbCrLf)
Open strTargetFile For Append As #filenum
For i = 0 To UBound(fileInfo) - 1
If i = intRow Then
Print #filenum, "你好"
End If
Next
Close #filenum
MsgBox "完毕"
End Sub
Private Sub Command1_Click()
Call tihuan("aa.txt", 3)
End Sub