Solved

err Log in a txt file

Posted on 1998-11-29
7
161 Views
Last Modified: 2010-05-03
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.




0
Comment
Question by:vern123
  • 5
  • 2
7 Comments
 

Author Comment

by:vern123
ID: 1447312
Edited text of question
0
 

Author Comment

by:vern123
ID: 1447313
Edited text of question
0
 

Author Comment

by:vern123
ID: 1447314
Edited text of question
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 8

Accepted Solution

by:
MikeP090797 earned 220 total points
ID: 1447315
Function Log(szFile as string, szMessage as string)
  Dim n as long
  n = freefile
  Open szFile for Append as #n
  Print #N, szMessage
  Close #N
End Function
0
 

Author Comment

by:vern123
ID: 1447316
Thanks mike, but I also need the function to add the file
(If it does not already exist) with the correct name/path
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1447317
It does that. The Append file access method creates the file if it doesn't exist already.
0
 

Author Comment

by:vern123
ID: 1447318
:)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now