-
I don't know if you want this:
The interval attribute of a timer control, a label, and an interval is set to 1000, and the enable attribute of the timer is false
dim i as integer
private sub command1_click()= true
end sub
private sub timer1_timer()= 120 - i
i = i + 1
if val( = 0 then
msgbox "It's time"
endend if
end sub
-
The interval property of the timer control sets the time in milliseconds.
1000 for 1 second.
2 minutes then you need to change the interval attribute to 120000
-
Add a timer1, a command1, a label1, and a txt to enter the limit time.
dim h as integer, m as integer, s as integer
private sub command1_click()
0msgbox h & "hours" & m & "minutes" & s & "seconds"
end sub
private sub form_load()
s = 0m = 0
h = = format(h, "00") &":" & format(m, "00") &":" & format(s, "00")
end sub
private sub timer1_timer()
s = s + 1
if s > 60 then
m = m + 1
end if
if m > 60 then
h = h + 1
end if
if m>=val(trim( and val(trim(>0 then
0= format(h, "00") &":" & format(m, "00") &":" & format(s, "00")
endifend sub
-
Simple use of timer: According to my understanding, timer is equivalent to a threaded task scheduler, and setting a new timer and setting its schedule method can easily decide what to do, how long to delay before executing, and how often to execute again.
How do I set the schedule method of the timer object?
Let's start with the signature of the schedule method:
You can see the list of parameters for the schedule method:
The Chinese meanings of delay and period are "delay" and "period", respectively. For a scheduled task, "delay" and "period" are the attributes of the scheduled task. Determines how many milliseconds (the unit of this parameter) a scheduled task needs to be delayed to start execution, and the size of the cycle in which the scheduled task is executed in a loop.
The first parameter is a bit more complicated for beginners. I'm new to it myself. TimerTask itself is an abstract class that implements the runnable interface, and students with thread knowledge are very clear that in the runnable interface, a run() method is declared.
This method is the unit of execution of the thread. When a thread is started, the work to be done by the manuscript is to execute the run() method.
The timertask abstract class implements the runnable interface, so the timertask also has a run() method. The run() method is a task to be executed by the thread, so leave this task to the scheduler method of the timer.
The timer then starts the thread task at the end of the delay time, and periodically loops.
In the above program, the purpose of the program is to extend the life cycle of the test method, so that the effect of the timer can be reflected, that is, 1 message is output to the console every 1 second.
end)
-
interval is the time of the timer cycle.
The first thing you need to understand is the concept of reentrant: simply put, it cannot be modified.
The explanation in the dividing line is that when you use the timer to judge an event in a loop, if the execution of the event takes longer than your timer to execute once, or takes more time, and your event has not been executed, your timer will be at the place where the instruction is executed in a loop.
This way the event to be executed by your event will be executed again.
If there are multiple timers executing the same event, or thread, if each timer makes a change to where it is executed, it is likely to have an incorrect effect on the instruction to be executed repeatedly. So the instruction segment to be executed by the timer is not modifiable.
Example: int a=1
timer1: timer2:
if(a>10) printf(a) ;If a>10 outputs a
Both timers have changed the value of a, and if a is equal to 11, at the moment when it is about to be output, timer2 squares a, so that it should have been 11 and it becomes 121
This A is not reentrant because it can be modified.
So the explanation is that if you use multiple timers to operate on some data, it is better that the variables you want to manipulate are not modified, that is, only reference and not modify. Reentrant means that it can be loaded into memory multiple times without being modified.
Wish. The lake is your eyes.
Dreams are full of stars. >>>More
First, Ctrl+F, in the menu bar - Analysis - Formulator There are commonly used formulas in the menu bar If you need to click New or import other existing formulas. >>>More
Like is a faint love, love is a faint like. If you like it but can't love it, it's fateless.
You yourself know that it's a waste of time, so you're still playing out of control? >>>More
糰 Pinyin: tuán Traditional Chinese characters: regiment radical: >>>More