Open FilePath For Input As #1
Do While Not EOF(1)
Line Input #1, strData
Loop
Close #1
Open txt For Output As #1
strData = "welcome"
Print #1, strData
'换行 Chr$(13) + Chr$(10)或vbCrLf
Open txt For Append As #2 '追加
Open txt For Binary As #3
Put #3, 4, "aaa"
打开文件数量是动态的情况下,文件号可以用freefile函数来生成:
Dim FileNum As Integer
LogMessage ="Some very important text"
FileNum = FreeFile
Open FName For Append As #FileNum
Print #FileNum, LogMessage
Close #FileNum ' close the file
End Sub