accumulative log

Hi,

The code i have currently only log in the current string.
How can i edit the code so that it "remembers" the old string plus add in the current string?

So the result is something like
10/10/2011 04:26:40 PM Strings
10/10/2011 04:26:45 PM Strings
11/10/2011 02:26:40 PM Strings


*Note: I am using vb script
Sub asd(o As GwxPick)
Call Write_in_File("C:\logfile.log", "Strings")
End Sub
Function Write_in_File(File, Content)
        Dim newFS
            Set newFS = CreateObject("Scripting.FileSystemObject")
            Set File_Name = newFS.OpenTextFile(File, 2, True)
            File_Name.Write Now & " " & Content
            File_Name.Close
            Set File_Name = Nothing
            Set newFS = Nothing
End Function

Open in new window

csharp_learnerAsked:
Who is Participating?
 
DhaestConnect With a Mentor Commented:
Yes you can, just add a newline constant after writing each line. So the next one will start a a new line

File_Name.Write Now & " " & Content & vbCrLf
0
 
DhaestCommented:
Try another opening mode

' OpenTextFile Method needs a Const value
' ForAppending = 8 ForReading = 1, ForWriting = 2
Const ForAppending = 8



http://www.computerperformance.co.uk/vbscript/vbscript_file_opentextfile.htm
Sub asd(o As GwxPick)
Call Write_in_File("C:\logfile.log", "Strings")
End Sub
Function Write_in_File(File, Content)
        Dim newFS
            Set newFS = CreateObject("Scripting.FileSystemObject")
            Set File_Name = newFS.OpenTextFile(File, 8, True)
            File_Name.Write Now & " " & Content
            File_Name.Close
            Set File_Name = Nothing
            Set newFS = Nothing
End Function

Open in new window

0
 
csharp_learnerAuthor Commented:
Can it be coded in a way the new string is written on a new line instead?
0
 
csharp_learnerAuthor Commented:
Thank you so much for your help.
0
 
DhaestCommented:
Glad to help you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.