Changing text in label with timer
Hi all,
I am new here and I have one problem. I have to implement code that will change text in label every second with timer. Text values are: "maximum" and "minimum", so text in label should change from "maximum" to "minimum" and vice versa every second (ok, timer interval = 1000).
I will appreciate if anyone can help me.
Thanks in advance
Re: Changing text in label with timer
Off the top of my head...
Use the timer.tick event.
In the timer1.tick event:
Code:
if label1.text = "max" then
label1.text = "min"
and vice versa.
Re: Changing text in label with timer
Thank you very much for quick response, I'll try this one...
Re: Changing text in label with timer
Try this with the timer interval set to 1000
Code:
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Static minmax As Boolean = False
minmax = Not minmax
If minmax Then
Label1.Text = "maximum"
Else
Label1.Text = "minimum"
End If
End Sub
Re: Changing text in label with timer
Thanks dbasnett,
I am new to VB, so please if you have time to explain to me line of code: minmax = Not minmax, which I don't understand at all.
Thank you in advance
Re: Changing text in label with timer
Not performs logical negation on the boolean(a true false data type). A boolean can have two values. Not changes the value to the opposite. Link for Not
If you put a Stop before the statement and then step through the code you will see this.
Re: Changing text in label with timer
Ok,I understand it.
Thank you very much once again. Cheers!