0

Hi All

I'm new to VB and trying to learn for a specific project - I've done plenty of VBA (although not for a year or two) in the past but that's my limit. I'm helping to manage some equipment which adds a new record to a csv log file every 15 mins. Whenever the value in the fourth column in that log changes to or from 0 (regardless of what it changes to or from), I want to fire an email off (two different emails - one for the value changing to 0 - i.e. turning off, and a different email for it changing from 0 - i.e. turning on). Can anyone point me in the right direction for some code for that?

I've been looking around for two days (at utilities as well as VB code) and haven't got any further than this thread:

http://www.daniweb.com/software-development/vbnet/threads/119377

thanks in advance!
Danny

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by dannydc
0

I would suggest to use a FileSystemWatcher and listen to the "Changed" event.

Dim watcher As New FileSystemWatcher with {.Path="C:\Logs",.NotifyFilter=NotifyFilters.LastWrite,.Filter="log.cvs",.EnableRaisingEvents = True}
AddHandler watcher.Changed, AddressOf OnChanged
''' Event handler
Private Sub OnChanged(source As Object, e As FileSystemEventArgs)
      'check CVS value and send mail
End Sub

Edited by GeekByChoiCe: n/a

0

Thanks for the response GBC and sorry - I wasn't clear. I think the code you posted is to monitor when the file changes but I can run it as a scheduled task as i know it updates every 15 mins. The bit I'm struggling most with is where to start with finding the last used row in a csv file, then comparing the two values in the last and second-to-last rows in column 'D' in that csv.

TIA
Danny

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.