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

📄 clock.frm

📁 VB编写的时钟显示代码可完成定时关机功能
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmFirst 
   Caption         =   "Timer Shutdown"
   ClientHeight    =   2970
   ClientLeft      =   2880
   ClientTop       =   2040
   ClientWidth     =   4575
   ControlBox      =   0   'False
   Icon            =   "clock.frx":0000
   LinkTopic       =   "Form1"
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   2970
   ScaleWidth      =   4575
   WindowState     =   1  'Minimized
   Begin VB.OptionButton optPM 
      Caption         =   "PM"
      Height          =   255
      Left            =   120
      TabIndex        =   9
      Top             =   2640
      Width           =   735
   End
   Begin VB.OptionButton optAM 
      Caption         =   "AM"
      Height          =   255
      Left            =   120
      TabIndex        =   8
      Top             =   2280
      Width           =   735
   End
   Begin VB.CommandButton cmdCurrent 
      Caption         =   "&Current ShutDown Time"
      Height          =   615
      Left            =   2400
      TabIndex        =   7
      Top             =   1440
      Width           =   2055
   End
   Begin VB.TextBox txtMinutes 
      Height          =   285
      Left            =   120
      TabIndex        =   4
      Top             =   1800
      Width           =   975
   End
   Begin VB.TextBox txtHours 
      Height          =   285
      Left            =   120
      TabIndex        =   3
      Top             =   1440
      Width           =   975
   End
   Begin VB.CommandButton cmdQuit 
      Caption         =   "E&xit"
      Enabled         =   0   'False
      Height          =   615
      Left            =   2400
      TabIndex        =   2
      Top             =   2280
      Width           =   2055
   End
   Begin VB.CommandButton cmdSet 
      Caption         =   "&Set"
      Height          =   615
      Left            =   1080
      TabIndex        =   1
      Top             =   2280
      Width           =   1215
   End
   Begin VB.Timer Timer1 
      Interval        =   1
      Left            =   0
      Top             =   0
   End
   Begin VB.Line Line1 
      X1              =   0
      X2              =   4560
      Y1              =   1320
      Y2              =   1320
   End
   Begin VB.Label lblMinute 
      Caption         =   "Minutes "
      Height          =   255
      Left            =   1200
      TabIndex        =   6
      Top             =   1800
      Width           =   1095
   End
   Begin VB.Label lblHour 
      Caption         =   "Hour"
      Height          =   255
      Left            =   1200
      TabIndex        =   5
      Top             =   1440
      Width           =   1095
   End
   Begin VB.Label lblTime 
      Alignment       =   2  'Center
      BeginProperty Font 
         Name            =   "Times New Roman"
         Size            =   36
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   975
      Left            =   0
      TabIndex        =   0
      Top             =   120
      Width           =   4455
   End
End
Attribute VB_Name = "frmFirst"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'***************************************************
'
'  This program shuts down your PC after 5 minutes
'  of switching  on if kept in start of windows
'
'   Programmed by Deepak Mehtani
'   Mail me at : deepakmehtani@123india.com
'
'***************************************************

'********************************'
'Double Click time to enable exit'
'********************************'

Private Const EWX_SHUTDOWN As Long = 1
Private Declare Function ExitWindowsEx Lib "user32" (ByVal dwOptions As Long, ByVal dwReserved As Long) As Long

Dim Hrs
Dim Mnt
Dim AMPM
Dim SetAlarm

Private Sub cmdCurrent_Click()
    MsgBox SetAlarm, , "Current Alarm Time"
End Sub

Private Sub cmdQuit_Click()
    End
End Sub

Private Sub cmdSet_Click()
   Dim h, m, nh, nm
    h = Hour(Time)
    If h > 12 Then
      h = h - 12
      optPM.Value = True
    Else
      optAM.Value = True
    End If
    m = Minute(Time)
    nm = m + 5
    If nm > 59 Then
       nm = nm - 59
       nh = h + 1
       If nh > 12 And AMPM = "AM" Then
          nh = nh - 12
          AMPM = "PM"
       ElseIf nh > 12 And AMPM = "PM" Then
          nh = nh - 12
          AMPM = "AM"
       End If
    Else
      nh = h
    End If
    txtHours.Text = nh
    If nm > 10 Then
       txtMinutes.Text = nm
    Else
       txtMinutes.Text = "0" & nm
    End If
    Hrs = txtHours.Text
    Mnt = txtMinutes.Text
    If optAM.Value = True Then
        AMPM = "AM"
    ElseIf optPM.Value = True Then
        AMPM = "PM"
    End If

    SetAlarm = Hrs + ":" + Mnt + ":00 " + AMPM
End Sub

Private Sub Form_Load()
    Me.Top = (Screen.Height - Me.Height) / 2
    Me.Left = (Screen.Width - Me.Width) / 2
    Call cmdSet_Click
End Sub

Private Sub lblTime_DblClick()
cmdQuit.Enabled = True
End Sub

Private Sub Timer1_Timer()
    lblTime.Caption = Time   ' Update time display.
    If SetAlarm = lblTime.Caption Then
        'shut down the computer
        lngResult = ExitWindowsEx(EWX_SHUTDOWN, 0&)
    End If
End Sub

⌨️ 快捷键说明

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