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

Recommended Answers

All 2 Replies

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.