📄 tim.frm
字号:
VERSION 5.00
Begin VB.Form Form0
BackColor = &H00C0E0FF&
BorderStyle = 1 'Fixed Single
Caption = "迷你定时器"
ClientHeight = 3630
ClientLeft = 45
ClientTop = 435
ClientWidth = 3900
ControlBox = 0 'False
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3630
ScaleWidth = 3900
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox Text1
BackColor = &H00C0FFFF&
ForeColor = &H00C00000&
Height = 315
Index = 2
Left = 3180
MaxLength = 2
TabIndex = 13
Text = "00"
Top = 2400
Width = 315
End
Begin VB.TextBox Text1
BackColor = &H00C0FFFF&
ForeColor = &H00C00000&
Height = 315
Index = 1
Left = 2700
MaxLength = 2
TabIndex = 12
Text = "20"
Top = 2400
Width = 315
End
Begin VB.TextBox Text1
BackColor = &H00C0FFFF&
ForeColor = &H00C00000&
Height = 315
Index = 0
Left = 2220
MaxLength = 2
TabIndex = 9
Text = "00"
Top = 2400
Width = 315
End
Begin VB.CheckBox Check1
BackColor = &H00C0E0FF&
Caption = "倒计时"
ForeColor = &H00008000&
Height = 315
Left = 360
TabIndex = 7
Top = 2400
Value = 1 'Checked
Width = 915
End
Begin VB.CommandButton BtSS
Caption = "启/停"
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 555
Left = 1500
TabIndex = 5
Top = 2880
Width = 1275
End
Begin VB.CommandButton BtExit
Caption = "Exit"
BeginProperty Font
Name = "Arial Narrow"
Size = 9
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 555
Left = 3000
TabIndex = 4
Top = 2880
Width = 555
End
Begin VB.Timer Timer1
Interval = 140
Left = 240
Top = 180
End
Begin VB.CommandButton BtClear
Caption = "清零"
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 555
Left = 300
TabIndex = 2
Top = 2880
Width = 975
End
Begin VB.Label Label7
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = ":"
ForeColor = &H00800000&
Height = 255
Left = 3000
TabIndex = 11
Top = 2460
Width = 195
End
Begin VB.Label Label6
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = ":"
ForeColor = &H00800000&
Height = 255
Left = 2520
TabIndex = 10
Top = 2460
Width = 195
End
Begin VB.Label Label5
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "预设时间"
ForeColor = &H00808000&
Height = 255
Left = 1260
TabIndex = 8
Top = 2460
Width = 915
End
Begin VB.Label Label4
BackColor = &H00C0FFFF&
BackStyle = 0 'Transparent
Caption = ".88"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF8080&
Height = 315
Left = 3000
TabIndex = 6
Top = 1800
Width = 615
End
Begin VB.Label Label3
Appearance = 0 'Flat
BackColor = &H00C0E0FF&
BackStyle = 0 'Transparent
Caption = "简易计时器"
BeginProperty Font
Name = "隶书"
Size = 26.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00008000&
Height = 555
Left = 540
TabIndex = 3
Top = 60
Width = 2835
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
BackColor = &H00C0FFFF&
BackStyle = 0 'Transparent
Caption = "12:34:56"
BeginProperty Font
Name = "宋体"
Size = 26.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF8080&
Height = 555
Left = 540
TabIndex = 1
Top = 1620
Width = 2415
End
Begin VB.Label Label1
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H00C0FFFF&
BackStyle = 0 'Transparent
Caption = "12:34:56"
BeginProperty Font
Name = "宋体"
Size = 26.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 495
Left = 540
TabIndex = 0
Top = 780
Width = 2535
End
Begin VB.Shape Shape1
BackColor = &H00C0FFFF&
BackStyle = 1 'Opaque
Height = 675
Left = 240
Top = 1560
Width = 3375
End
Begin VB.Shape Shape2
BackColor = &H00C0FFFF&
BackStyle = 1 'Opaque
Height = 675
Left = 240
Top = 720
Width = 3375
End
End
Attribute VB_Name = "form0"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim t0, tm, tp, t1, ks
Sub display()
Dim s, t
If Check1.Value = 1 Then t = tm - tp Else t = tp
'
s = d2s(Int(t / 60) Mod 60) + ":" + d2s(Int(t) Mod 60)
If t >= 3600 Then s = d2s(Int(t / 3600)) + ":" + s
Label2.Caption = s
Label4.Caption = "." + d2s(t * 100 Mod 100)
End Sub
Function d2s(n)
Dim s
s = Right(Format(n + 1000), 2)
d2s = s
End Function
Private Sub Check1_Click()
display
BtSS.SetFocus
End Sub
Private Sub BtClear_Click()
t0 = Timer
tp = 0
display
BtSS.SetFocus
End Sub
Private Sub BtExit_Click()
Dim a$
BtSS.SetFocus
Form1.Visible = True
Form1.Enabled = True
Form1.Left = form0.Left
Form1.Top = form0.Top - Form1.Height
If Form1.Top < 0 Then Form1.Top = form0.Top + form0.Height
Form1.SetFocus
form0.Enabled = False
End Sub
Private Sub BtSS_Click()
Dim i
ks = Not ks
If ks Then
If tp >= tm Then BtClear_Click
t0 = Timer - tp
Label2.ForeColor = &HC0&
Label4.ForeColor = &HC0&
Else
tp = Timer - t0
Label2.ForeColor = &HFF8080
Label4.ForeColor = &HFF8080
End If
'BtClear.Enabled = Not ks
BtExit.Enabled = Not ks
'Check1.Enabled = Not ks
For i = 0 To 2: Text1(i).Enabled = Not ks: Next
If tp >= tm Then tp = tm
display
End Sub
Private Sub Form_Load()
t0 = Timer
tp = 0
t1 = t0
ks = False
tm = (Val(Text1(0)) * 60 + Val(Text1(1))) * 60 + Val(Text1(2))
display
End Sub
Private Sub Text1_lostfocus(Index As Integer)
Dim ia, t, i
ia = Int(Val(Text1(Index)))
tm = (Val(Text1(0)) * 60 + Val(Text1(1))) * 60 + Val(Text1(2))
If tm <= 0 Then tm = 3600
t = tm
For i = 2 To 0 Step -1
Text1(i).Text = d2s(t Mod 60)
t = Int(t / 60)
Next
BtClear_Click
End Sub
Private Sub Timer1_Timer()
Dim t, kc
t = Timer
If Abs(t - t1) >= 1 Then
Label1.Caption = Time$
t1 = t
End If
If ks Then
tp = t - t0
If tp >= tm Then
tp = tm
Timer1.Enabled = False
BtSS_Click
Timer1.Enabled = True
End If
display
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -