Link to home
Start Free TrialLog in
Avatar of vern123
vern123

asked on

err Log in a txt file

I need A function so that if I call the function and it records/post the string to the last entry of the textfile specified in the pathname.

Private Function(PathName as string,ErrText as string)

 
if the function were called 4 times, A further example

Private Function("c:/err/err.txt","err1")
Private Function("c:/err/err.txt","err2")
Private Function("c:/dd/other.txt","otherfile")
Private Function("c:/err/err.txt","err3")

the resulting file err.txt would look like in c:/err/
err1
err2
err3

the resulting file other.txt would look like in c:/dd/
otherfile

if file exists in dir it would append the text
if file is not found in dir then a new one must be created.
The file should be closed and saved after.

I need the complete working code for this Function

Thank you.




Avatar of vern123
vern123

ASKER

Edited text of question
Avatar of vern123

ASKER

Edited text of question
Avatar of vern123

ASKER

Edited text of question
ASKER CERTIFIED SOLUTION
Avatar of MikeP090797
MikeP090797

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vern123

ASKER

Thanks mike, but I also need the function to add the file
(If it does not already exist) with the correct name/path
It does that. The Append file access method creates the file if it doesn't exist already.
Avatar of vern123

ASKER

:)