用VB做个倒计时的软件
用VB做个倒计时的软件要求为3分钟
有暂停和开始的
谢谢了,
用VB做个倒计时的软件要求为3分钟
有暂停和开始的
谢谢了,
答案:看代码:dim i,j as integer '定义整数形变量存输入的倒计时分和秒
'载入窗体函数
Private Sub Form_Load()
timer1.enabled=false
timer1.interlval=1000i=val(trim(text1.text))
j=val(trim(text2.text))
End Sub
'开始倒计时按钮
private sub command1_click()
timer1.enabled=true
end sub
'暂时倒计时按钮
private sub command2_click()
timer1.enabled=false
end sub
Private Sub Timer1_Timer()if i=0 and j=0 then
msgbox "倒计时结束,结束时间为:" & time
end
endif
j=j-1
if i<>0 then
if j=0 then
i=i-1
j=59
endif
endif
text1.text=i
text2.text=j
End Sub
2个command控件,一个timer控件,一个text控件,具体代码如下:
Option Explicit
Dim H, M, S As IntegerPrivate Sub Command1_Click()
Timer1.Enabled = True
End SubPrivate Sub Command2_Click()
Timer1.Enabled = False
End SubPrivate Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
H = 0
M = 3
S = 0
Text1.Text = Format(H, "00") + ":" + Format(M, "00") + ":" + Format(S, "00")
Text1.FontBold = True
Text1.FontSize = 15
End SubPrivate Sub Timer1_Timer()
Ta: S = S - 1
If S >= 0 Then
Text1.Text = Format(H, "00") + ":" + Format(M, "00") + ":" + Format(S, "00")
Else
S = 60
M = M - 1
If M = 0 Then
Timer1.Enabled = False
Else
GoTo Ta
End If
End If
End Sub这里有.
http://hi.zhaoxi.net/cbm666/blog/item/ba13d1c8f8f8ff137e3e6f3f.html
上一个:求每天定时关机的VB代码?
下一个:VB怎么检测在目录下的文件?