第1个回答 2007-05-27
dim shi as long
dim fen as long
dim miao as long
Private Sub form_load()
fen=val(0)
miao=val(0)
shi=val(0)
end sub
Private Sub command2_click()
fen=inputbox("时间","输入","")
if fen>=val(60) then shi=val(shi)+val(1)
end sub
Private Sub command1_click()
Timer1.Enabled=true
end sub
Private Sub Timer1_timer()
if miao<>val(0) then
miao=miao-1
end if
if miao=val(0) and fen <>val(0) then
fen=fen-1
miao=60-1
end if
if miao=val(0) and fen =val(0) and shi <>val(0) then
shi=shi-1
fen=60-1
miao=60-1
end if
if miao=val(0) and fen =val(0) and shi =val(0) then
msgbox("时间用尽了!")
timer1.Enabled=False
end if
text1.text="还剩" & shi & "时" & fen & "分" & miao & "秒"
end sub本回答被提问者采纳
第2个回答 2007-05-27
Dim h As Integer
Dim m As Integer
Dim s As Integer
Private Sub Command1_Click()
m = InputBox("输入以分钟为单位数值", "设置", "10")
s = m * 60
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Command1.Caption = "设置"
h = 0: m = 0: s = 0
Text1.Locked = True
End Sub
Private Sub Timer1_Timer()
If s > 0 Then
s = s - 1
m = (s \ 60) Mod 60
h = (m \ 60) Mod 60
Text1.Text = Format(h, "00") & ":" & Format(m, "00") & ":" & Format(s Mod 60, "00")
Else
Timer1.Enabled = False
End If
End Sub
由于时间关系不做太多判断了,,判断之类的东西自己写吧