Sub TextStream_Write()
Dim FSO As New FileSystemObject
Dim MyTS As TextStream
Dim MyPath As String
MyPath = CurrentProject.Path & "\Sample2\sample.txt"
Set MyTS = FSO.OpenTextFile(MyPath, ForWriting) 'ForAppending は追記
MyTS.Write "田村桃太郎"
MyTS.WriteBlankLines 1
MyTS.WriteLine "田村小太郎"
MyTS.Close
Set MyTS = Nothing
End Sub
Sub TextStream_Read()
Dim FSO As New FileSystemObject
Dim MyTS As TextStream
Dim MyPath As String
MyPath = CurrentProject.Path & "\Sample2\Sample.txt"
Set MyTS = FSO.OpenTextFile(MyPath, ForReading)
'2文字読み込み
MsgBox MyTS.Read(2)
'2文字読み込み
MsgBox MyTS.Read(2)
'改行まで読み込み
MsgBox MyTS.ReadLine
'全て読み込み
MsgBox MyTS.ReadAll
MyTS.Close
Set MyTS = Nothing