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

📄 秒表.frm

📁 简单时间程序,可以定时执行任务,显示当前时间到前台窗口
💻 FRM
字号:
VERSION 5.00
Begin VB.Form 秒表 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "秒表"
   ClientHeight    =   1650
   ClientLeft      =   4440
   ClientTop       =   6030
   ClientWidth     =   3150
   ControlBox      =   0   'False
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   110
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   210
   ShowInTaskbar   =   0   'False
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Left            =   2655
      Top             =   -120
   End
   Begin VB.CommandButton Command1 
      Caption         =   "开始(&S)"
      Height          =   375
      Left            =   154
      TabIndex        =   1
      Top             =   930
      Width           =   825
   End
   Begin VB.CommandButton Command2 
      Caption         =   "复位(R)"
      Height          =   375
      Left            =   1163
      TabIndex        =   2
      Top             =   930
      Width           =   825
   End
   Begin VB.CommandButton Command3 
      Caption         =   "关闭(&C)"
      Height          =   375
      Left            =   2172
      TabIndex        =   3
      Top             =   930
      Width           =   825
   End
   Begin VB.PictureBox Picture1 
      Height          =   735
      Left            =   83
      ScaleHeight     =   675
      ScaleWidth      =   2925
      TabIndex        =   0
      Top             =   120
      Width           =   2985
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   24
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   555
         Left            =   0
         TabIndex        =   5
         Top             =   60
         Width           =   2925
      End
   End
   Begin VB.Label Label2 
      Alignment       =   2  'Center
      Caption         =   "精确到百分之一秒,请单击开始"
      Height          =   195
      Left            =   315
      TabIndex        =   4
      Top             =   1380
      Width           =   2520
   End
End
Attribute VB_Name = "秒表"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function GetTickCount Lib "kernel32" () As Long
Public hms, hms1, hms2, js3 As Long

Sub Command1_Click()
If Command1.Caption = "开始(&S)" Then '根据caption确定启动或停止秒表
 Timer1.Enabled = True
 Timer1.Interval = 1
 Command1.Caption = "暂停(&P)"
 Command1.SetFocus
 hms1 = GetTickCount
 Command2.Enabled = False
Else
 Timer1.Enabled = False
 Command1.Caption = "开始(&S)"
 Command1.SetFocus
 js3 = hms
 Command2.Enabled = True
End If
End Sub

Private Sub Command2_Click()
Timer1.Enabled = False '复位
Label1.Caption = "00" + ":" + "00" + ":" + "00" + "." + "00"
hms = 0
js3 = 0
Command1.Caption = "开始(&S)"
Command1.SetFocus
End Sub

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

Private Sub Form_Activate()
Command1.SetFocus '焦点移到开始上
End Sub

Private Sub Form_Load()
Label1.Caption = "00" + ":" + "00" + ":" + "00" + "." + "00"
hms = 0
js3 = 0
   Dim sz(1) As String
读取 "mb", "left", sz(0), 主窗体.MyName
If sz(0) = "No" Then
Me.Left = (Screen.Width - Me.Width) / 2
Else
Me.Left = Val(sz(0))
End If
读取 "mb", "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)
 写入创建 "mb", "left", Me.Left, 主窗体.MyName
 写入创建 "mb", "top", Me.Top, 主窗体.MyName
End Sub

Private Sub Timer1_Timer()
hms2 = GetTickCount '主程序,秒表记时及显示
hms = (hms2 - hms1) \ 10 + js3
hm = hms Mod 100
xs = hms \ 360000
fs = (hms \ 6000) Mod 60
ms = (hms \ 100) Mod 60
If Len(CStr(xs)) < 2 Then '不足两位的补0
 xs = "0" + CStr(xs)
End If
If Len(CStr(fs)) < 2 Then
 fs = "0" + CStr(fs)
End If
If Len(CStr(ms)) < 2 Then
 ms = "0" + CStr(ms)
End If
If Len(CStr(hm)) < 2 Then
 hm = "0" + CStr(hm)
End If
Label1.Caption = xs & ":" & fs & ":" & ms & "." & hm
End Sub

⌨️ 快捷键说明

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