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

📄 时间控制.frm

📁 简单时间程序,可以定时执行任务,显示当前时间到前台窗口
💻 FRM
字号:
VERSION 5.00
Begin VB.Form 时间控制 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "时间调整"
   ClientHeight    =   1605
   ClientLeft      =   4515
   ClientTop       =   4215
   ClientWidth     =   3885
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   1605
   ScaleWidth      =   3885
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton Command2 
      Caption         =   "取消(&C)"
      Height          =   285
      Left            =   1995
      TabIndex        =   2
      Top             =   1155
      Width           =   1065
   End
   Begin VB.Frame Frame2 
      Caption         =   "时间"
      Height          =   795
      Left            =   2010
      TabIndex        =   6
      Top             =   225
      Width           =   1815
      Begin VB.TextBox Text2 
         Alignment       =   2  'Center
         Height          =   270
         Index           =   2
         Left            =   1260
         Locked          =   -1  'True
         TabIndex        =   12
         Top             =   337
         Width           =   285
      End
      Begin VB.TextBox Text2 
         Alignment       =   2  'Center
         Height          =   270
         Index           =   1
         Left            =   660
         TabIndex        =   11
         Top             =   337
         Width           =   285
      End
      Begin VB.TextBox Text2 
         Alignment       =   2  'Center
         Height          =   270
         Index           =   0
         Left            =   60
         TabIndex        =   10
         Top             =   337
         Width           =   285
      End
      Begin VB.Label Label6 
         Caption         =   "秒"
         Height          =   165
         Left            =   1620
         TabIndex        =   15
         Top             =   390
         Width           =   165
      End
      Begin VB.Label Label5 
         Caption         =   "分"
         Height          =   165
         Left            =   1020
         TabIndex        =   14
         Top             =   390
         Width           =   165
      End
      Begin VB.Label Label4 
         Caption         =   "时"
         Height          =   165
         Left            =   420
         TabIndex        =   13
         Top             =   390
         Width           =   165
      End
   End
   Begin VB.Timer Timer1 
      Interval        =   100
      Left            =   240
      Top             =   1110
   End
   Begin VB.CommandButton Command1 
      Caption         =   "更新(&R)"
      Height          =   285
      Left            =   825
      TabIndex        =   1
      Top             =   1155
      Width           =   1065
   End
   Begin VB.Frame Frame1 
      Caption         =   "日期"
      Height          =   795
      Left            =   60
      TabIndex        =   0
      Top             =   225
      Width           =   1815
      Begin VB.TextBox Text1 
         Alignment       =   2  'Center
         Height          =   270
         Index           =   2
         Left            =   1275
         TabIndex        =   9
         Text            =   " "
         Top             =   330
         Width           =   285
      End
      Begin VB.TextBox Text1 
         Alignment       =   2  'Center
         Height          =   270
         Index           =   1
         Left            =   750
         TabIndex        =   8
         Text            =   " "
         Top             =   330
         Width           =   285
      End
      Begin VB.TextBox Text1 
         Alignment       =   2  'Center
         Height          =   270
         Index           =   0
         Left            =   60
         TabIndex        =   7
         Text            =   " "
         Top             =   330
         Width           =   465
      End
      Begin VB.Label Label3 
         Caption         =   "日"
         Height          =   195
         Left            =   1560
         TabIndex        =   5
         Top             =   375
         Width           =   225
      End
      Begin VB.Label Label2 
         Caption         =   "月"
         Height          =   195
         Left            =   1050
         TabIndex        =   4
         Top             =   375
         Width           =   225
      End
      Begin VB.Label Label1 
         Caption         =   "年"
         Height          =   195
         Left            =   525
         TabIndex        =   3
         Top             =   375
         Width           =   225
      End
   End
End
Attribute VB_Name = "时间控制"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim sfxg As Boolean
Private Sub Command1_Click()
Date = Text1(0).Text & "-" & Text1(1).Text & "-" & Text1(2).Text '刷新时间
Time = Text2(0).Text & ":" & Text2(1).Text & ":" & Text2(2).Text
Call 主窗体.tisi
Unload Me
End Sub

Private Sub Command2_Click()
 Unload Me
 主窗体.Show
End Sub

Private Sub Form_Load()
Text1(0).Text = Year(Date) '获取系统时间及日期
Text1(1).Text = Month(Date)
Text1(2).Text = Day(Date)
Text2(0).Text = Hour(Time)
Text2(1).Text = Minute(Time)
Text2(2).Text = Second(Time)
Command1.Enabled = False
sfxg = False
   Dim sz(1) As String
读取 "sjtz", "left", sz(0), 主窗体.MyName
If sz(0) = "No" Then
Me.Left = (Screen.Width - Me.Width) / 2
Else
Me.Left = Val(sz(0))
End If
读取 "sjtz", "top", sz(1), 主窗体.MyName
If sz(1) = "No" Then
Me.Top = (Screen.Height - Me.Height) / 2
Else
Me.Top = Val(sz(1))
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
 写入创建 "sjtz", "left", Me.Left, 主窗体.MyName
 写入创建 "sjtz", "top", Me.Top, 主窗体.MyName
End Sub

Private Sub Text1_click(Index As Integer)
sfxg = True '点击进入编辑状态
Command1.Enabled = True
End Sub
Private Sub Text2_click(Index As Integer)
sfxg = True
Command1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If sfxg = False Then
Text1(0).Text = Year(Date) '自动刷新显示的时间及日期
Text1(1).Text = Month(Date)
Text1(2).Text = Day(Date)
Text2(0).Text = Hour(Time)
Text2(1).Text = Minute(Time)
Text2(2).Text = Second(Time)
Else
Text2(2).Text = Second(Time)
End If
End Sub

⌨️ 快捷键说明

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