change label.text when data changes

jkatshor

Member
Joined
Mar 20, 2009
Messages
11
Programming Experience
Beginner
I have a form with label1.text that always runs.

label1.text = "operator1"

i have read in a text file and saved data from it as a string.

i want to continually read this file and when the string data changes i want label1.text = "operator2"

i cannot figure out how to change the label1.text when the data changes.
any tips?

thanks in advance
 
VB.NET:
If newFileContents <> oldFileContents Then
    label1.Text = "operator2"
End If
Obviously you need to read the data from the file into those variables in the first place.
 
hi friend
keep one more variable as old data variable
and compare it with the present one and change the text
 
I understand the suggestions you posted and have already tried something similar. To try to explain my question a little more, this app always runs without buttons, I want to continually read a file and capture a portion of it as a string. If the file does not change the string remains the same. When the file changes I want to change a label1.text to read a preassigned value. My problem is I do not know how to continually read this file. any suggestions??

Thanks
 
You can't "continually" read a file. I presume you mean intermittently, perhaps at regular intervals. If so then you would just use a Timer and read the file on its Tick or Elapsed event, depending on which type of Timer you use.

Another alternative might be to use a FileSystemWatcher. In that case you'd be notified when the file changes so you would only read it if and when there were changes to read.
 
Back
Top