How to Countdown Timer control in VB

Source: Internet
Author: User

1, program load operation: Private Sub form_load () ' form is loaded automatically
timer1.interval = 1000 ' Set the tick period to 1 seconds note The default timing unit is milliseconds, or 1/1000 seconds

2. Define a time variable. Can be substituted for the Caption property of a control, such as Label12.caption
3. Drag and drop the timer control to the program interface
4, set the countdown: Double-click the clock control, enter the timing rules, such as Label12.caption = label12.caption + 1
5. Set the method (i.e. action) to be taken when the time value reaches a certain condition. You can use the IF statement. If Label12.caption =60,then Unload Form1, note the difference between a block if statement and a line if statement

Here is an example:
Private Sub form_load () ' form loads automatically when the following actions are
timer1.interval = 1000 ' chronograph frequency set to 1 seconds
End Sub
Private Sub timer1_timer ()
label12.caption = Label12.caption-1 ' in seconds
End Sub
Private Sub Commandsure_click ()
If label12.caption =
s = MsgBox ("Confirm the submission, cancel the refill!") ", 1," prompt message ") ' Pop-up dialog box
If s = 1 Then
f = MsgBox ("Submit message successfully, please click to confirm exit System", 0, "")
Unload Form1 ' form off
Else
Load Form1 ' reinitialization
form1.enabled = True ' Allow refill
timer1.enabled = True ' Continue timing
commandsure.enabled = True ' OK button available
End If
End Sub

How to Countdown Timer control in VB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.