📄 four_frm.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 7560
ClientLeft = 60
ClientTop = 450
ClientWidth = 11265
LinkTopic = "Form1"
ScaleHeight = 7560
ScaleWidth = 11265
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command4
Caption = "退出"
Height = 855
Left = 7440
TabIndex = 8
Top = 5280
Width = 3255
End
Begin VB.CommandButton Command3
Caption = "复位"
Height = 855
Left = 7440
TabIndex = 2
Top = 3600
Width = 3255
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 1000
Left = 5280
Top = 4560
End
Begin VB.CommandButton Command2
Caption = "停止倒计时"
Height = 855
Left = 7440
TabIndex = 1
Top = 2040
Width = 3255
End
Begin VB.CommandButton Command1
Caption = "开始倒计时"
Height = 855
Left = 7440
TabIndex = 0
Top = 360
Width = 3255
End
Begin VB.Label Label7
Caption = "秒"
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3120
TabIndex = 10
Top = 5400
Width = 495
End
Begin VB.Label Label6
Caption = "Label6"
BeginProperty Font
Name = "宋体"
Size = 20.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 735
Left = 360
TabIndex = 9
Top = 5280
Width = 2295
End
Begin VB.Label Label5
Caption = "天"
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3120
TabIndex = 7
Top = 3600
Width = 495
End
Begin VB.Label Label4
Caption = "Label4"
BeginProperty Font
Name = "宋体"
Size = 20.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 735
Left = 360
TabIndex = 6
Top = 3600
Width = 2295
End
Begin VB.Label Label3
Caption = "年"
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3120
TabIndex = 5
Top = 1920
Width = 495
End
Begin VB.Label Label2
Caption = "Label2"
BeginProperty Font
Name = "宋体"
Size = 20.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 735
Left = 360
TabIndex = 4
Top = 1920
Width = 2295
End
Begin VB.Label Label1
BackColor = &H00FFFFC0&
Caption = "Label1"
BeginProperty Font
Name = "宋体"
Size = 20.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 1095
Left = 360
TabIndex = 3
Top = 360
Width = 5415
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim nYear As Long, nDay As Long, tYear As Long, tDay As Long
Dim nSec As Long, tSec As Long
Dim strNow1 As String, strNow2 As String
Dim strEnd1 As String, strEnd2 As String
Dim ly As Integer, cy As Integer
'nYear,nDay,nSec为当前年和当前年距离年底的天数以及当前天已经过去的秒数,
'tYear,tDay,tSec为预设定时间截止点的年,该年元月1日到时间截止点的天数以及时间截止点当天零点到截止时间的秒数
'ly,cy分别为闰年和平年
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Command3_Click()
Timer1.Enabled = False
Label2.Caption = "0"
Label4.Caption = "000"
Label6.Caption = "00000000"
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Form_Load()
strEnd1 = InputBox$("请输入倒计时截止日期:(格式:月-日-年)")
strEnd2 = InputBox$("请输入倒计时截止时间:(格式:时:分:秒)")
Label1.Caption = "距离" + Right(strEnd1, 4) + "年" + Left(strEnd1, 2) + "月" + Mid(strEnd1, 3, 2) + "日" + "还有:"
tYear = Val(Right(strEnd1, 4))
tDay = (Val(Left(strEnd1, 2)) - 1) * 30 + Val(Mid(strEnd1, 3, 2))
tSec = Val(Left(strEnd2, 2)) * 3600 + Val(Mid(strEnd2, 4, 2)) * 60 + Val(Right(strEnd2, 2))
End Sub
Private Sub Timer1_Timer()
strNow1 = Format(Now, "mm/dd/yyyy")
strNow2 = Format(Now, "hh:mm:ss")
nYear = Val(Right(strNow1, 4))
If nYear Mod 4 = 0 And nYear Mod 100 <> 0 Or nYear Mod 400 = 0 Then
ly = 1
nDay = 366 - (Val(Left(strNow1, 2) - 1) * 30 + Val(Mid(strNow1, 4, 2)))
Else
nDay = 365 - (Val(Left(strNow1, 2) - 1) * 30 + Val(Mid(strNow1, 4, 2)))
cy = 1
End If
nSec = Val(Left(strNow2, 2)) * 3600 + Val(Mid(strNow2, 4, 2) - 1) * 60 + Val(Right(strNow2, 2))
showSecond
showDay
showYear
End Sub
Sub showDay()
If ly = 1 Then
Label4.Caption = 366 - tDay - nDay
ElseIf cy = 1 Then
Label4.Caption = 365 - tDay - nDay
End If
End Sub
Sub showYear()
Label2.Caption = tYear - nYear
End Sub
Sub showSecond()
nSec = 86400 - nSec + tSec
If nSec > 86400 Then
nSec = nSec - 86400
nDay = nDay + 1
End If
Label6.Caption = nSec
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -