-
Upstairs ** is so long, it's still simple?
Speechless. I wrote one for you, this is really simple and practical, hehe!
Add a timer control.
Adjust the interval attribute to.
Millisecond. That is.
1 second. Add two.
Add a button.
Start the countdown.
That's it. The procedure is as follows:
private
subform_load()
falseend
subprivate
subtimer1_timer()
endifendsub
private
subcommand1_click()
trueend
If you don't understand something, please contact me!
-
It's as simple as subtracting the present time from the target time. Time subtraction should be!
-
1. First of all, create a project, and add three command buttons in the window, change the caption to "set countdown", "start countdown", "continue", change the caption property of form form1 to "countdown", add a timer control, and add a text box, and set the interface to the following figure.
2. Clear the attributes in the text of the text box, and then adjust the attributes of the font font to small four, so as to facilitate the next observation, and remember to adjust the background color attribute backcolor to light yellow.
6. Define these three variables in the general section of the ** window: dim h as integer, m as integer, s as integer'These three quantities are stored separately, such as hours, minutes, and seconds, as shown in the following figure.
8. Then close the ** window, press F5 to run the program, and then click the command button "Set Countdown", then an input dialog box will pop up, be sure to remember to enter the number of minutes at this time, the number is 1, and then OK, as shown in the figure:
9. Finally, be sure to click the command button "Start Countdown", and then the text box will display the countdown time, and it will continue to change, at this time you can see that the time is changing, which is to realize the countdown function, as shown in the figure:
-
dim i as integer
private sub command1_click() '(The timer starts working).
The countdown has started and this button cannot be clicked again.
true 'start the timer.
1000' refresh the interface every second.
i=60 'To count down the time, in this case let's say 60 seconds, you can actually change the end sub
private sub timer1 timer()i = i-1 'decrement.
if i > 0 then
Remaining" & i & "seconds"
else It's time"
Stop the timer. 'true' button is available.
end if
end sub
-
With the timer control,interval sets the trigger time, and then defines a global variable for counting, for example:
dim js as long
private sub form_load()= 1000 'Triggers once every 1 second.
label1 = ""
js = 10
end sub
private sub timer1_timer()if js = 0 then end
label1 = "Countdown:" & val(js) &"seconds to turn off"
js = js - 1
end sub
-
First empty: = true
i = 10 'Change to the second empty number of times you want to countdown: i = i - 1
Third empty: ="Left:" & i & "seconds"
Fourth empty: = false
In addition, you need to set the interval attribute of timer1 to 1000, that is, the timer event is executed once every 1 second.
-
dim i as long
private sub command1_click() '(The timer starts working).
end sub
private sub timer1_timer()i = i + 1
if i < 10 then '10 seconds.
Remaining" & 10-i & "seconds"
else "It's time"
i = 0 0end if
end sub
-
i=200 'The countdown time you want to set.
i=i-1i=200
-
Methodological steps. 1. Open.
vb(visual
basic)
software, new standards.
exe project, design the window according to the figure below. The middle three.
The textbox is used to enter the query date, and their Name property is set to .
y,m,d。The three below it.
label is used to indicate the current date, with their Name property set to each.
cy,cm,cd。There are also two labels below the "Calculate" button, which are used to indicate the difference between the two dates, please set the name of the label box on the left.
t, the name of the label box on the right is set to:
s。These settings are prepared for later programming**.
2. The layout of the form has been completed, and the formal program design will begin. The first step, when you first open the program, you have to extract today's date. Double-click the blank space of the window, and the ** window will pop up, write as follows**.
The green text is a comment, you can refer to its meaning, you don't have to write it when writing **.
3. The second step is to check whether there is any error in the number after entering the date. The year must be.
The month must be.
, and the date needs to specify the corresponding range according to the current year and month. Double-click the first text box.
y, enter the **window, write as follows**, there is also a comment.
4. After judging whether the entered date is wrong, the next step is to calculate today, as well as the set date, and each distance from the Common Era.
Year. Month. How many days are there? Double-click the "Calculate" button and write ** as below. There are also annotations.
5. Okay, all the ** has been written, you can click the "Run" button on the toolbar to test the effect. If you are very satisfied, you can also click the "Generate Project Command" under the "File" menu to directly generate the application, so that you can run it at any time!
-
<>dim i as integer
private sub command1 click() timer to start working).
The countdown has started and this button cannot be clicked again.
true 'start the timer.
1000' refresh the interface every second.
i=60 'The time you want to count down to 60 seconds, in this case, is assumed to be 60 seconds, which you can actually change.
end sub
private sub timer1 timer()i = i-1 'decrement.
if i > 0 then
Remaining"&i & s"
It's time"Stop the timer.
'true' button is available.
end if
end sub
-
About (question being answered).
This solution is a humiliation of the timer control and a lack of learning. If the countdown time is more than 5 seconds, it will be while....Wend's loop design is not enough, if you use his function to count down for 10 minutes, you can't jump out of the loop action for 10 minutes, let alone continue to start the second countdown and the third countdown.
I won't talk about the principle, just tell you the key points of the design.
It is correct to use multiple timer controls to handle multiple countdowns, with countdowns of 600 seconds, 480 seconds, and 360 seconds as explanations, to accurately timer is not to subtract 1 or subtract each time in the timer control, which does not mean that the time is close to 1 second or 1 millisecond. Rather, think of the event as "the frequency rate of the number of times the check is made", such as:
The future time to get the countdown Present time + 600 seconds = future time.
The interval of the timer event is set to 100 ms (the error value of the system is more than 7-15 ms because the entire resource is busy).
Each timer event checks whether the variable in the future time is due to the current computer time, rather than checking from 600-i each time to see if it is 0
If this method will have an error of more than 200 milliseconds, then I will tell you the reason, this error is a quality problem of the crystal frequency system of the computer motherboard. The quality of the server's motherboard crystal frequency system may also deviate from the standard time by a few seconds per day.
Note the principle that the first 599 seconds can be 500 milliseconds each time because the system is busy, but the error between the last decisive 1 second expiration time and the system time will never exceed 200 milliseconds, which is twice as much as interval=100ms.
If you're interested, try using a do....loop or while....The WEND cycle checks whether the 600 seconds expire, even if you add doevents and sleep, it not only takes up about 30% of the system resources and slows down the system speed, but also makes other controls of its own program, and other events of the ** have no chance to run.
Try using 10 timer controls at the same time, and you'll see that the 10 countdown controls take up less than 10% of the system's resources
I once saw that the xx propaganda function can be set to automatically click the mouse every 1 millisecond, and I laughed, regardless of whether it is a supercomputer or not, it takes more than 50 milliseconds to complete the exchange of mouse click information with the remote server.
If you have any questions about this content, please continue to ask questions, and I will continue to reply to them when I have time.
Insert 3 texts, 1 command
private sub form_load()= "1000" 'Blood volume. >>>More
Is there any raw data? What is the interface like? Where does the grade data come from?
Version 2 supports the library edb
Support for library specs >>>More
The least amount of money to live for a month, this month is the first thing to do is to remove all unnecessary expenses! Then all that remains is the necessary expenses. Eat, drink, live and travel! >>>More
Depending on how much you buy, MX500, MX510, IE3 are high-end mice. >>>More