📄
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "电子倒计时器"
ClientHeight = 2310
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 2310
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.Timer Timer1
Interval = 1000
Left = 3840
Top = 720
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1200
TabIndex = 0
Top = 600
Width = 495
End
Begin VB.CommandButton Command1
Caption = "倒计时"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1560
TabIndex = 4
Top = 1425
Width = 975
End
Begin VB.TextBox Text2
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2280
TabIndex = 3
Top = 600
Width = 495
End
Begin VB.Label Label3
Caption = "秒"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 2400
TabIndex = 2
Top = 240
Width = 375
End
Begin VB.Label Label2
Caption = "分钟"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 1200
TabIndex = 1
Top = 240
Width = 495
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim m As Integer, s As Integer '声明模块级变量
Private Sub Form_Load()
Timer1.Interval = 1000 '设置每隔1秒触发1次Timer事件
Timer1.Enabled = False '关闭计时器
End Sub
Private Sub Command1_Click() '“倒计时”
m = Val(Text1.Text)
s = Val(Text2.Text)
Timer1.Enabled = True '打开计时器
End Sub
Private Sub Timer1_Timer()
If s > 0 Then
s = s - 1
Else
If m > 0 Then
m = m - 1
s = 59
End If
End If
Text1.Text = Format(m, "00")
Text2.Text = Format(s, "00")
If s = 0 And m = 0 Then
Beep '响铃,即让喇叭发一声响
MsgBox "计时结束"
Unload Me
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -