⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 倒计时工具
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      Height          =   735
      Left            =   1560
      TabIndex        =   11
      Top             =   2640
      Width           =   255
   End
   Begin VB.Label Label8 
      BackStyle       =   0  'Transparent
      Caption         =   ":"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   36
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   855
      Left            =   1560
      TabIndex        =   10
      Top             =   1560
      Width           =   255
   End
   Begin VB.Label Label7 
      BackColor       =   &H0000FF00&
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   36
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   855
      Left            =   1920
      TabIndex        =   5
      Top             =   4080
      Width           =   3495
   End
   Begin VB.Label Label6 
      BackStyle       =   0  'Transparent
      Caption         =   "秒"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   36
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   720
      TabIndex        =   4
      Top             =   4200
      Width           =   855
   End
   Begin VB.Label Label5 
      BackColor       =   &H000080FF&
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   36
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   855
      Left            =   1920
      TabIndex        =   3
      Top             =   2880
      Width           =   3495
   End
   Begin VB.Label Label4 
      BackStyle       =   0  'Transparent
      Caption         =   "天"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   36
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   720
      TabIndex        =   2
      Top             =   2760
      Width           =   735
   End
   Begin VB.Label Label2 
      BackColor       =   &H8000000D&
      BackStyle       =   0  'Transparent
      Caption         =   "年"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   36
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   720
      TabIndex        =   1
      Top             =   1680
      Width           =   855
   End
   Begin VB.Label Label1 
      BackColor       =   &H00C0E0FF&
      BackStyle       =   0  'Transparent
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   21.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   975
      Left            =   240
      TabIndex        =   0
      Top             =   240
      Width           =   5775
   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
Label3.Caption = "0"
Label5.Caption = "000"
Label7.Caption = "00000000"
End Sub

Sub showDay()                           '剩余天数
 If ly = 1 Then
        Label5.Caption = -(366 - tDay - nDay + 1)
    ElseIf cy = 1 Then
        Label5.Caption = -(365 - tDay - nDay)
    End If 'tDay为当前年的最大天数值,nDay为当前年中已过天数
End Sub

Sub showYear()

If Label5.Caption < 0 Then
    Label3.Caption = tYear - nYear - 1
    If tYear Mod 4 = 0 And tYear Mod 100 <> 0 Or tYear Mod 400 = 0 Then
  
        Label5.Caption = 366 + Label5.Caption
    Else
     Label5.Caption = 365 + Label5.Caption

    End If
Else
Label3.Caption = tYear - nYear
End If

'剩余年份
                                   'tYear为倒计时年份,nYear为当前年份
End Sub

Sub showSecond()
 nSec = 86400 - nSec + tSec
    If nSec > 86400 Then
        nSec = nSec - 86400
        nDay = nDay + 1
    End If
    Label7.Caption = nSec      'nSec为当天已过秒数,86400为1天的秒数
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, 3, 2)) * 60 + Val(Right(strEnd2, 2))
End Sub



Private Sub command6_Click()
Label12.Caption = DateAdd("h", -13, Now)
End Sub

Private Sub command7_Click()
Label13.Caption = DateAdd("h", -8, Now)
End Sub

Private Sub command5_Click()
Label11.Caption = Format(Now, "yyyy/mm/dd") + " " + Format(Now, "hh:mm:ss")
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)) * 60 + Val(Right(strNow2, 2))
    showSecond
    showDay
    showYear
End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -