[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

writing into a log file

Hi,

I'm using a software with the support of VB that has a function to track data change.
How can I write these changes on a logfile with the Pc time and date?
Private Sub ObjOPCGroup_DataChange(ByVal TransactionID As Long, ByVal NumItems As Long, ClientHandles() As Long, ItemValues() As Variant, Qualities() As Long, TimeStamps() As Date)
    Dim i As Integer
    Dim strChanges As String
    For i = 1 To NumItems
        strChanges = strChanges & Array_Items(ClientHandles(i)) & " New Values " & ItemValues(i) & vbCrLf
    Next i
    
    'Write strChanges into log file???
    
End Sub

Open in new window

0
csharp_learner
Asked:
csharp_learner
1 Solution
 
twolCommented:
I could jot a littl code for you, but look at this link...it is pretty thorough.
http://www.builderau.com.au/program/windows/soa/Reading-and-writing-text-files-with-VB-NET/0,339024644,320267367,00.htm
0
 
csharp_learnerAuthor Commented:
thanks for your reply,

I tried with the following code, but the line
oWrite.WriteLine("{0,10:dd MMMM}{....
kept returning an error of missing "="

is there a syntax error?
Private Sub ObjOPCGroup_DataChange(ByVal TransactionID As Long, ByVal NumItems As Long, ClientHandles() As Long, ItemValues() As Variant, Qualities() As Long, TimeStamps() As Date)
    Dim i As Integer
    Dim strChanges As String
    
    Dim oFile As System.IO.File
    Dim oRead As System.IO.StreamReader
    
    For i = 1 To NumItems
        strChanges = strChanges & Array_Items(ClientHandles(i)) & " New Values " & ItemValues(i) & vbCrLf
    Next i

    oRead = oFile.OpenText("C:\transActive\bin\SIG_Schematic_log.txt")
    oWrite.WriteLine("{0,10:dd MMMM}{0,10:hh:mm tt}{1,25:C}", Now(),strChanges)
    oWrite.Close()
    
End Sub

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now