|
-
Apr 15th, 2013, 04:54 AM
#1
Thread Starter
New Member
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
-
Apr 15th, 2013, 05:11 AM
#2
Member
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.
-
Apr 15th, 2013, 05:22 AM
#3
Thread Starter
New Member
Re: Changing text in label with timer
Thank you very much for quick response, I'll try this one...
-
Apr 15th, 2013, 06:32 AM
#4
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
-
Apr 15th, 2013, 06:56 AM
#5
Thread Starter
New Member
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
-
Apr 15th, 2013, 07:05 AM
#6
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.
-
Apr 15th, 2013, 07:27 AM
#7
Thread Starter
New Member
Re: Changing text in label with timer
Ok,I understand it.
Thank you very much once again. Cheers!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|