那个高手帮我看看问题在那里 VB

来源:百度知道 编辑:UC知道 时间:2024/05/29 18:36:32
Dim RecTime As Variant
Dim miao As String

Private Sub Command2_Click()
Timer1.Enabled = True
Timer1.Interval = 1000
RecTime = Time
Label2.Caption = "开始时间:" & RecTime
End Sub
Private Sub Timer1_Timer()
Label1.Caption = "运行时间:" & Format(Time - RecTime, "hh:mm:ss")
miao = " 00:00:10"
If miao = RecTime Then
MsgBox "时间到"
End If
End Sub
Private Sub Command1_Click()
Timer1.Enabled = False
End Sub

以上是代码 用二个Label 一个Timer 二个 Command 是想让
10秒后自动弹出一个窗口提示时间到的 别的都正常 就是窗口弄不出来 急呀

问题简单,发现两个,,

miao = " 00:00:10"有空格 miao = "00:00:10"

If miao = RecTime 应该改成
If miao = Format(Time - RecTime, "hh:mm:ss") Then

下面是改好的 调试通过
Private Sub Timer1_Timer()
Label1.Caption = "运行时间:" & Format(Time - RecTime, "hh:mm:ss")
miao = "00:00:10"
If miao = Format(Time - RecTime, "hh:mm:ss") Then
MsgBox "时间到"
End If
End Sub