kodan
Jul 7 2004, 03:58 AM
Hi to all.
With the help of many people in UA, I found the code to write text file.
I want use it as a simple log to record date and time users logs in.
Dim strFile As String
Dim fhand As Integer
strFile = "UsersLog.txt"
fhand = FreeFile
Open strFile For Output As #fhand
LogDT = "[" & Now & "] -- " & UCase(strUserID)
Print #fhand, LogDT
Close #fhand
This is part of the code that mishej suggested me (thanx!) and works fine, but every time the routine write the file, replace it with new data instead of adding a new line in the existing text file.
Any ideas ?
Thanx in advance
BenPurser
Jul 7 2004, 04:56 AM
Don't know squat about this, but a quick perusal of the Help turned up the Append mode, so this line:
Open strFile For Output As #fhand
you might want to change to
Open strFile For Append As #fhand
I don't know what happens if you try to use Append before the file is first created. It may or may not create it if it doesn't already exist.
HTH
Ben
truittb
Jul 7 2004, 06:37 AM
FYI
QUOTE
I don't know what happens if you try to use Append before the file is first created. It may or may not create it if it doesn't already exist.
If the file specified by pathname doesn't exist, it is created when a file is opened for Append, Binary, Output, or Random modes
kodan
Jul 7 2004, 08:47 AM
Ok everything works very good ! thanx to all
rack
Aug 5 2004, 10:14 AM
using '97 and coming up with "User-type type not defined" on the Print command, this looks like a reference problem, anyone know which reference would correct this?
Thanks
Rack
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.