Solved

err Log in a txt file

Posted on 1998-11-29
7
163 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

828 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