|
-
Jan 12th, 2011, 02:17 PM
#1
Thread Starter
New Member
delay/timer function?
Hi!
i want to do this with the delay of in interval with the loop of 10 times.
for n=0 to 10
label.text="0"
time delay of 1 second
label1.text="1"
end loop
But when i m using executing the loop completes it iterations and timer just show work in last iteration.
-
Jan 12th, 2011, 02:25 PM
#2
Re: delay/timer function?
Add a timer component to the form, set the interval to 1000. That will do the timing, but you will need to change the logic. Whenever the timer runs down it raises the tick event, so you won't have your loop in one place the way you currently do. Instead, have a counter variable (an integer) at form scope. In the timer tick event, increment that counter and check whether it is 10. If it is, disable the timer. As long as it is not 10, change your labels accordingly.
My usual boring signature: Nothing
 
-
Jan 13th, 2011, 06:32 AM
#3
Thread Starter
New Member
Re: delay/timer function?
i want to run the timer again and again for 10 times.
-
Jan 13th, 2011, 07:24 AM
#4
Re: delay/timer function?
You already mentioned that, what you mean is that you want to run your code 10 times. As already explained a timer runs every second, you control how many times it runs by stopping and starting it. There is another method, but unless you want the side effects I would use SH suggestion first.
-
Jan 13th, 2011, 12:05 PM
#5
Re: delay/timer function?
1. Add a timer to your form. Set the interval to 1000, enabled to true.
2. Double click on the timer you've just added to the form. This will create a Timer.Tick event handler for you in code. You then paste this inside that sub:
Code:
Static counter as integer = 0
'Display the current value of counter
Label1.Text = counter.ToString()
'Increment counter by 1
counter += 1
'Reset counter back to 0 if it's > 10
If counter > 10 then
counter = 0
End If
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Jan 13th, 2011, 01:20 PM
#6
Thread Starter
New Member
Re: delay/timer function?
now got the concept. thanks. i was think to repeat the timer with the loop.
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
|