Avatar of csharp_learner
csharp_learnerFlag for Singapore

asked on 

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

VB ScriptVisual Basic Classic

Avatar of undefined
Last Comment
Dirk Haest
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

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

Avatar of csharp_learner
csharp_learner
Flag of Singapore image

ASKER

Can it be coded in a way the new string is written on a new line instead?
ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of csharp_learner
csharp_learner
Flag of Singapore image

ASKER

Thank you so much for your help.
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Glad to help you
Visual Basic Classic
Visual Basic Classic

Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.

165K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo