Put #1, , "asdf" Put #1, , vbBack Put #1, , vbBack '因为 vbCrLf 长度为 2
Reference: Microsoft Scripting Runtime Private Sub Command1_Click() Dim fso As New Scripting.FileSystemObject Dim f As TextStream Set f = fso.OpenTextFile("D:\aaa.dat", ForWriting, True) f.Write "qwert" '不添加回车换行,如果需要添加回车换行可以使用writeline f.Close Set f = Nothing Set fso = Nothing
End Sub
pring 是写一行,除非你把文件当作一个串
Kill App.Path & "\aaa.dat" Open App.Path & "\aaa.dat" For Binary Access Write As #1 Put #1, , "qwert" Close #1
Put #1, , vbBack
Put #1, , vbBack
'因为 vbCrLf 长度为 2
Private Sub Command1_Click()
Dim fso As New Scripting.FileSystemObject
Dim f As TextStream
Set f = fso.OpenTextFile("D:\aaa.dat", ForWriting, True)
f.Write "qwert" '不添加回车换行,如果需要添加回车换行可以使用writeline
f.Close
Set f = Nothing
Set fso = Nothing
End Sub
Open App.Path & "\aaa.dat" For Binary Access Write As #1
Put #1, , "qwert"
Close #1