在程时裏怎麼计时,并显示在label1裏??

来源:百度知道 编辑:UC知道 时间:2024/06/04 17:19:43
一开启程式就开始计时,1秒,2秒,3秒,4秒.5秒.6秒,,,,,,,,,,,,,,,,,,,,并显示在label1裏,然后时间过了3分钟后就弹出msgbox"你好"

Dim n As Integer

Private Sub Form_Load()
n = 1
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
Label1.Caption = n & "秒"
If n < 180 Then
n = n + 1
Else
Timer1.Enabled = False
MsgBox "你好!", vbInformation
End If
End Sub

Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 1000
Label1.Caption = "0秒"
End Sub

Private Sub Timer1_Timer()
Static p As Integer
p = p + 1
Label1.Caption = str(p)+"秒"

If p Mod 180 = 0 Then MsgBox "你好"
End Sub

Public a As Integer
Private Sub Form_Load()
Timer1.Interval = 1000
a = 0
End Sub

Private Sub Timer1_Timer()
a = a + 1
If a Mod 180 = 0 Then MsgBox "你好"
Label1.Caption = a & "秒"
End Sub

public a '可以设置在通用XX里的静态变量保存