vb 进来看看哪里错了?

来源:百度知道 编辑:UC知道 时间:2024/06/08 23:38:30
一个关于时钟的小程序,运行后按开始怎么没反应?
Dim t As Integer

Private Sub Command1_Click()
t = 60 * Val(Text1.Text)
Timer1.Enabled = True

End Sub

Private Sub Timer1_Timer()
Dim m, s As Integer
t = t - 1
m = Int(t / 60)
s = t Mod 60
Label1.Caption = m & "分" & "36" & "秒"
If (t = 0) Then
Timer1.Enabled = False
MsgBox ("时间到!")
End If

End Sub

没有设置timer的Interval属性

添加
Private Sub Form_Load()
Timer1.Interval = 1000
End Sub
看看

是不是要倒计时的效果?
Option Explicit

Dim t As Long

Private Sub Command1_Click()
t = 60 * Val(Text1.Text)
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()
Dim m, s As Integer
t = t - 1
m = Int(t / 60)
s = t Mod 60
Label1.Caption = m & "分" & s & "秒"
If (t = 0) Then
Timer1.Enabled = False
MsgBox ("时间到!")
End If

End Sub

Dim t As Integer

Private Sub Command1_Click()
t = 60 * Val(Text1.Text)
Timer1.Interval = 1000'*******************
Timer1.Enabled = True

End Sub

Private Sub Timer1_Timer()
Dim m, s As Integer
t = t - 1
m = Int(t / 60)
s = t Mod 60
Label1.Caption = m & "分" & s & "秒" '***************