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

📄 stopwatch.frm

📁 这是一个计时器
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   BackColor       =   &H00FFC0C0&
   Caption         =   "秒表"
   ClientHeight    =   2415
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   2415
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command3 
      BackColor       =   &H00C0FFC0&
      Caption         =   "复位"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   3000
      MaskColor       =   &H00008000&
      Style           =   1  'Graphical
      TabIndex        =   8
      Top             =   1800
      Width           =   1335
   End
   Begin VB.CommandButton Command2 
      BackColor       =   &H00C0FFC0&
      Caption         =   "停止计时"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   1680
      MaskColor       =   &H00008000&
      Style           =   1  'Graphical
      TabIndex        =   7
      Top             =   1800
      Width           =   1335
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00404000&
      Height          =   1215
      Left            =   240
      TabIndex        =   1
      Top             =   240
      Width           =   4215
      Begin VB.Label LabelM 
         Alignment       =   2  'Center
         BackColor       =   &H00800000&
         Caption         =   "00"
         BeginProperty Font 
            Name            =   "黑体"
            Size            =   26.25
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000FFFF&
         Height          =   615
         Left            =   600
         TabIndex        =   6
         Top             =   360
         Width           =   735
      End
      Begin VB.Label LabelS 
         Alignment       =   2  'Center
         BackColor       =   &H00800000&
         Caption         =   "00"
         BeginProperty Font 
            Name            =   "黑体"
            Size            =   26.25
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000FFFF&
         Height          =   615
         Left            =   1680
         TabIndex        =   5
         Top             =   360
         Width           =   735
      End
      Begin VB.Label LabelMS 
         Alignment       =   2  'Center
         BackColor       =   &H00800000&
         Caption         =   "00"
         BeginProperty Font 
            Name            =   "黑体"
            Size            =   26.25
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000FFFF&
         Height          =   615
         Left            =   2880
         TabIndex        =   4
         Top             =   360
         Width           =   735
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         BackColor       =   &H00800000&
         Caption         =   "'"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   26.25
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000FFFF&
         Height          =   615
         Left            =   1320
         TabIndex        =   3
         Top             =   360
         Width           =   375
      End
      Begin VB.Label Label2 
         Alignment       =   2  'Center
         BackColor       =   &H00800000&
         Caption         =   "''"
         BeginProperty Font 
            Name            =   "楷体_GB2312"
            Size            =   26.25
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H0000FFFF&
         Height          =   615
         Left            =   2400
         TabIndex        =   2
         Top             =   360
         Width           =   495
      End
   End
   Begin VB.CommandButton Command1 
      BackColor       =   &H00C0FFC0&
      Caption         =   "开始计时"
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   360
      MaskColor       =   &H00008000&
      Style           =   1  'Graphical
      TabIndex        =   0
      Top             =   1800
      Width           =   1335
   End
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   100
      Left            =   0
      Top             =   1440
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
    Option Explicit
    Dim mse, se, mi As Integer
    Dim starttime As Single
    
    '  开始计时
    Private Sub Command1_Click()
    
        Timer1.Enabled = True
        starttime = Timer '起始点时刻
        '  设置按钮的状态
        Command1.Enabled = False
        Command2.Enabled = True
        Command3.Enabled = False
    
    End Sub
    '  停止计时
    Private Sub Command2_Click()
        
        Timer1.Enabled = False
        '  设置按钮的状态
        Command2.Enabled = False
        Command3.Enabled = True
        
    End Sub
    '  复位计时器
    Private Sub Command3_Click()
    
        LabelM.Caption = Format(0, "00")
        LabelS.Caption = Format(0, "00")
        LabelMS.Caption = Format(0, "00")
        Command1.Enabled = True
        mse = 0
        se = 0
        mi = 0
        
    End Sub
    '  初始计时器
    Private Sub Form_Load()
    
        Timer1.Enabled = False
        Timer1.Interval = 10
        mse = 0
        se = 0
        mi = 0
        Command2.Enabled = False
        Command3.Enabled = False
    
    End Sub
    
    '  计时过程中显示时间
    Private Sub Timer1_Timer()
        Dim sec As String
        Dim second As Long
        Dim point As Integer
        
        '  获取流逝时间,从中提取分、秒和毫秒并标签中显示出来
        sec = CStr(Timer - starttime)
        point = InStr(sec, ".")
        mse = Mid(sec, point + 1, 2)
        LabelMS.Caption = Format(mse, "00")
        If point > 1 Then
            second = CLng(Left(sec, point - 1))
            se = second Mod 60
            mi = (second - se) / 60
        End If
        If se <> CInt(LabelS.Caption) Then
            LabelS.Caption = Format(se, "00")
        End If
        If mi <> CInt(LabelM.Caption) Then
            LabelM.Caption = Format(mi, "00")
        End If
        
    End Sub

⌨️ 快捷键说明

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