Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TextStream and a little question!

Status
Not open for further replies.

SurvivorTiger

Programmer
Jul 9, 2002
265
US
Hi everyone,
This is my code:

Dim fso As FileSystemObject
Dim tStream As TextStream
Set fso = New FileSystemObject
Set tStream = fso.CreateTextFile("C:\whatever.txt", True)
With tStream
.WriteLine MonthView1.Day
.WriteLine txtHours.Text
.WriteLine txtWhatever.Text
.WriteBlankLines 1
.Close
End With

What I want to do is that the next time this code gets executed, i don't want it to overwrite the new info on the same lines, i want it to write those after the linke break...Any ideas?


AIM: survivertiger & Ye This Is Me
 
Hi

From the CreateTextFile method MSDN page ...

Code:
object.CreateTextFile(filename[, overwrite[, unicode]])

overwrite Optional. Boolean value that indicates if an existing file can be overwritten. The value is True if the file can be overwritten; False if it can't be overwritten. If omitted, existing files are not overwritten.

ie - TextStream provides Read and Write but no Append capability.

I suggest that you try using the open command - something like

Code:
    Dim x
    x = FreeFile
    Open "c:\tmp\stream.txt" For Append As #x
    Print #x, "AAA"
    Print #x, "BBB"
    Print #x, "CCC"
    Close #x

Hope this helps ...


Hope this helps ...
 
If you use the OpenAsTextStream method, which will allow you detail what file write mode you want (read Write or Append)

To use this method, you need a file object which you either create or open existing. I am sure you can find all of the methods for this in MSDN

Take Care

Matt
If at first you don't succeed, skydiving is not for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top