现在需要一个VB程序,给我代码就可以了。用于倒计时,时间为5分钟,显示...
发布网友
发布时间:2023-12-26 09:13
我来回答
共1个回答
热心网友
时间:2024-08-23 18:04
窗体放一个Label和一个Timer控件
Dim m As Integer, s As Integer, ms As Integer
Private Sub Form_Load()
Label1.Font.Size = 50
Timer1.Interval = 10
Timer1.Enabled = True
m = 5
End Sub
Private Sub Timer1_Timer()
If ms > 0 Then
ms = ms - 1
Else
ms = 99
If s > 0 Then
s = s - 1
Else
s = 59
If m > 0 Then
m = m - 1
Else
ms = 0
s = 0
End If
End If
End If
If m = 0 And s = 0 And ms = 0 Then
Label1.Caption = "GAME OVER"
Beep
Timer1.Enabled = False
Else
Label1.Caption = m & ":" & Format(s, "00") & ":" & Format(ms, "00")
End If
End Sub