📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
AutoRedraw = -1 'True
BorderStyle = 1 'Fixed Single
Caption = "倒计时"
ClientHeight = 2745
ClientLeft = 3270
ClientTop = 1635
ClientWidth = 3990
ControlBox = 0 'False
Icon = "FORM1.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
PaletteMode = 1 'UseZOrder
ScaleHeight = 2745
ScaleWidth = 3990
Begin VB.Timer Timer1
Enabled = 0 'False
Left = 480
Top = 840
End
Begin VB.CommandButton Command4
Caption = "退出"
Height = 375
Left = 2760
TabIndex = 8
Top = 2160
Width = 735
End
Begin VB.CommandButton Command3
Caption = "置零"
Enabled = 0 'False
Height = 375
Left = 1920
TabIndex = 7
Top = 2160
Width = 615
End
Begin VB.CommandButton Command2
Caption = "暂停"
Height = 375
Left = 1200
TabIndex = 6
Top = 2160
Width = 615
End
Begin VB.CommandButton Command1
Caption = "开始"
Height = 375
Left = 480
TabIndex = 5
Top = 2160
Width = 615
End
Begin VB.TextBox Text3
Alignment = 2 'Center
Height = 285
Left = 2520
MultiLine = -1 'True
TabIndex = 4
Top = 480
Width = 375
End
Begin VB.TextBox Text2
Alignment = 2 'Center
Height = 285
Left = 1800
MultiLine = -1 'True
TabIndex = 3
Top = 480
Width = 375
End
Begin VB.TextBox Text1
Alignment = 2 'Center
Height = 285
Left = 1080
MultiLine = -1 'True
TabIndex = 2
Top = 480
Width = 375
End
Begin VB.Label Label6
Alignment = 2 'Center
Caption = "秒"
Height = 255
Left = 2520
TabIndex = 12
Top = 840
Width = 375
End
Begin VB.Label Label5
Alignment = 2 'Center
Caption = "分钟"
Height = 255
Left = 1800
TabIndex = 11
Top = 840
Width = 375
End
Begin VB.Label Label4
Alignment = 2 'Center
Caption = "小时"
Height = 255
Left = 1080
TabIndex = 10
Top = 840
Width = 375
End
Begin VB.Label Label3
Alignment = 2 'Center
Caption = "剩余时间"
BeginProperty Font
Name = "MS Sans Serif"
Size = 13.5
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1200
TabIndex = 9
Top = 1080
Width = 1575
End
Begin VB.Label Label2
Alignment = 2 'Center
Caption = "设定时间"
Height = 255
Left = 1080
TabIndex = 1
Top = 120
Width = 1695
End
Begin VB.Label Label1
Alignment = 2 'Center
BackColor = &H0000FFFF&
Caption = "00:00:00"
BeginProperty Font
Name = "Arial"
Size = 14.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 375
Left = 1200
TabIndex = 0
Top = 1560
Width = 1575
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Hours As Integer
Dim Minutes As Integer
Dim Seconds As Integer
Dim Time As Date
Private Sub Mydisplay()
'记录用户的输入
Hours = Val(Text1.Text)
Minutes = Val(Text2.Text)
Seconds = Val(Text3.Text)
'将数字转变为时间
Time = TimeSerial(Hours, Minutes, Seconds)
'在Label1中显示时间
Label1.Caption = Format$(Time, "hh") & ":" & Format$(Time, "nn") & ":" & Format$(Time, "ss")
End Sub
Private Sub Command1_Click()
'激活Timer控件
Timer1.Enabled = True
Command3.Enabled = False
End Sub
Private Sub Command2_Click()
'暂停时间记录
Timer1.Enabled = False
Command3.Enabled = True
End Sub
Private Sub Command3_Click()
'重置时间
Hours = 0
Minutes = 0
Seconds = 0
Time = 0
Text1.Text = " "
Text2.Text = " "
Text3.Text = " "
Text1.SetFocus 'put curser in the hour text box
End Sub
Private Sub Command4_Click()
'退出程序
End
End Sub
Private Sub Form_Load()
'使窗口居中
Form1.Top = (Screen.Height - Form1.Height) / 2
Form1.Left = (Screen.Width - Form1.Width) / 2
Timer1.Interval = 1000
Hours = 0
Minutes = 0
Seconds = 0
Time = 0
End Sub
Private Sub Text1_Change()
Mydisplay
End Sub
Private Sub Text2_Change()
Mydisplay
End Sub
Private Sub Text3_Change()
Mydisplay
End Sub
Private Sub Timer1_Timer()
'动态改变时间
Timer1.Enabled = False
If (Format$(Time, "hh") & ":" & Format$(Time, "nn") & ":" & Format$(Time, "ss")) <> "00:00:00" Then 'Counter to continue loop until 0
Time = DateAdd("s", -1, Time)
Label1.Visible = False
Label1.Caption = Format$(Time, "hh") & ":" & Format$(Time, "nn") & ":" & Format$(Time, "ss")
Label1.Visible = True
Timer1.Enabled = True
Else
Timer1.Enabled = False
Beep
Beep
Command3.Enabled = True
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -