急,求助!! VB计时器的设计! (请进看要求)

来源:百度知道 编辑:UC知道 时间:2024/09/22 11:24:24
一个计时器,要求能让使用者自己打一个时间然后自动倒计时.
显示分秒即可

一个timer1,enabled=false,interval=1000,一个label,caption=""。

代码:
Dim stime As Date

Private Sub Form_Load()
on error goto err
stime = InputBox("time(00:00:00)", "倒计时输入,格式: hh-mm-ss")
timer1.enabled = true
err:
End Sub

Private Sub Timer1_Timer()
if stime = #12:00:00 AM# then
msgbox "时间到!"
timer1.enabled = false
else
stime = stime - #12:00:01 AM#
label1.caption = stime
end if
End Sub

启动,输入倒计时时间如
00:10:00 (10分钟)

一个timer1,enabled=false,interval=1000
在text1中输入分,在text2中输入秒
单击command1开始倒计时
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If Val(Text2.Text) <> 0 Then
Text2.Text = Val(Text2.Text) - 1
Else
Text1.Text = Val(Text1.Text) - 1
Text2.Text = 59
End If
If Val(Text1.Text) = 0 And Val(Text2.Text) = 0 Then