I have "real world" digital inputs from a LabJack U12. I would like to keep track of when each of them occur, and for how long.
I have no trouble with the LabJack.... this is strictly a VB write to file and read from file issue...because I don't know how to do it
What I am looking for is how can I write 3 values for each on/off event to a file and then read the three values back and keep track of all the values, so that I can use them for calculations.
I have found examples that write a few things to a file and then read them back... and that works, but then I can't figure out how to iterate through the entire file of multiple event "writings" . I am an old geezer and unfamiliar with the methods used today
I like how this works but I can't figure out how to "read it back, three at a time... At this point the "f" and "c" are just experimental placeholders.
Every on / off event from the LabJack U12 would append to the end of the file with three numbers , a start DateTime, an end DateTime, and a duration.... I don't know how many events there might be in a given time period .
how can i read this back from a file, three at a time and iterate through until I have read them all ?
Thank you
I have no trouble with the LabJack.... this is strictly a VB write to file and read from file issue...because I don't know how to do it
What I am looking for is how can I write 3 values for each on/off event to a file and then read the three values back and keep track of all the values, so that I can use them for calculations.
I have found examples that write a few things to a file and then read them back... and that works, but then I can't figure out how to iterate through the entire file of multiple event "writings" . I am an old geezer and unfamiliar with the methods used today
I like how this works but I can't figure out how to "read it back, three at a time... At this point the "f" and "c" are just experimental placeholders.
Every on / off event from the LabJack U12 would append to the end of the file with three numbers , a start DateTime, an end DateTime, and a duration.... I don't know how many events there might be in a given time period .
how can i read this back from a file, three at a time and iterate through until I have read them all ?
VB.NET:
'StartTime was filled last time to this sub
EndTime = Date.Now
Dim duration As TimeSpan = EndTime.Subtract(StartTime)
Dim c As String = "Abc13"
Dim f As Single = 23.45
dblDuration = duration.TotalSeconds 'using seconds, this can be integer TotalSeconds is double
sngDuration = dblDuration
My.Computer.FileSystem.CurrentDirectory = "C:\Users\Realolman\Desktop"
Dim fs As New FileStream("binary.txt", FileMode.Append, FileAccess.Write)
Dim bwriter As New BinaryWriter(fs)
bwriter.Write(c)
bwriter.Write(dblDuration)
bwriter.Write(f)
bwriter.Close()
fs.Close()
StartTime = Date.Now
End Sub
Thank you
Last edited by a moderator: