Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

I need to create a history of all user events in a text file, anyone know how

Posted on 2006-06-13
5
Medium Priority
?
183 Views
Last Modified: 2010-04-30
I need to create a record of all events in a program as print it as data to a text file. I need to be able to get the users name, the filename, the date and time. To this I will add the processing used as strings. I ahave used code to write and read from ini file, will it be along those lines?
0
Comment
Question by:eneate
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 16893994
Not sure exactly what you're asking for here...

Below is simple code that demonstrates how to output to a text file:

Option Explicit

Private outputLog As String

Private Sub Form_Load()
    outputLog = "c:\someFile.txt"
End Sub

Private Sub Command1_Click()
    Dim i As Integer
    For i = 1 To 10
        WriteLineToFile outputLog, "Line" & i
    Next i
End Sub

Private Sub WriteLineToFile(ByVal fileName As String, ByVal outputLine As String)
    On Error GoTo fileError
   
    Dim ff As Integer
    ff = FreeFile
    Open fileName For Append As #ff
    Print #ff, outputLine
    Close #ff
    Exit Sub
   
fileError:
    MsgBox "Error writing to " & fileName & vbCrLf & Err.Description, vbExclamation, "Error " & Err.Number
End Sub
0
 

Author Comment

by:eneate
ID: 16894165
Thanks, what commands would I use to obtain the date time
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16894228
You can do things like..

    ' this one is dependent upon your system settings
    Debug.Print Now ' 6/13/2006 7:55:19 AM
   
    Dim dt As String
    dt = Format(Now, "dd mmm yyyy")
    Debug.Print dt ' 13 Jun 2006
   
    Dim tm As String
    tm = Format(Now, "h:nn:ss am/pm")
    Debug.Print tm ' 7:57:43 am
   
    Dim dtTm As String
    dtTm = Format(Now, "dd mmm yyyy @ h:nn:ss am/pm")
    Debug.Print dtTm ' 13 Jun 2006 @ 7:58:56 am
0
 

Author Comment

by:eneate
ID: 16894308
Thanks, that gives me somewher to start from.
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 16894395
...further to Idle_Mind's response...

Debug.Print Format(Now, "Long Date") & " " & Format(Now, "Long Time")

or

Debug.Print Format(Now, "Short Date") & " " & Format(Now, "Short Time")

Can also be used, and take the format of the date/time presentation from the ("International Settings" or) "Regional and Language Options" (depending on which version of MS-Windows you are using) applet in the Windows Control Panel.

PS. You asked about the filename - did you mean the filename of the Visual Basic application (App.EXEName)?

BFN,

fp.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

610 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