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

📄 form2.frm

📁 时钟转动比较好
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "时钟"
   ClientHeight    =   3795
   ClientLeft      =   60
   ClientTop       =   375
   ClientWidth     =   5580
   LinkTopic       =   "Form1"
   ScaleHeight     =   3795
   ScaleWidth      =   5580
   StartUpPosition =   3  '窗口缺省
   Begin VB.Timer Timer1 
      Left            =   240
      Top             =   2640
   End
   Begin VB.Frame Frame1 
      Height          =   3015
      Left            =   240
      TabIndex        =   0
      Top             =   480
      Width           =   3255
      Begin VB.Label Label4 
         Caption         =   "12"
         Height          =   255
         Left            =   1440
         TabIndex        =   4
         Top             =   240
         Width           =   255
      End
      Begin VB.Label Label3 
         Alignment       =   2  'Center
         Caption         =   "6"
         Height          =   255
         Left            =   1440
         TabIndex        =   3
         Top             =   2640
         Width           =   375
      End
      Begin VB.Label Label2 
         Alignment       =   2  'Center
         Caption         =   "3"
         Height          =   255
         Left            =   2880
         TabIndex        =   2
         Top             =   1440
         Width           =   255
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         Caption         =   "9"
         Height          =   255
         Left            =   120
         TabIndex        =   1
         Top             =   1440
         Width           =   255
      End
      Begin VB.Line LineS 
         BorderColor     =   &H000000FF&
         X1              =   1560
         X2              =   960
         Y1              =   1560
         Y2              =   840
      End
      Begin VB.Line LineM 
         BorderColor     =   &H000080FF&
         BorderWidth     =   3
         X1              =   1560
         X2              =   2280
         Y1              =   1560
         Y2              =   1200
      End
      Begin VB.Line LineH 
         BorderColor     =   &H00C00000&
         BorderWidth     =   4
         X1              =   1560
         X2              =   2160
         Y1              =   1560
         Y2              =   1800
      End
   End
   Begin VB.Label Label5 
      Caption         =   "Label5"
      Height          =   375
      Left            =   360
      TabIndex        =   5
      Top             =   120
      Width           =   1935
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const PI = 3.14159
Private len_S As Single, len_M As Single, len_H As Single

Private Sub Form_Load()
'计算指针的长度
len_S = Sqr((LineS.Y2 - LineS.Y1) ^ 2 + (LineS.X2 - LineS.X1) ^ 2)
len_M = Sqr((LineM.Y2 - LineM.Y1) ^ 2 + (LineM.X2 - LineM.X1) ^ 2)
len_H = Sqr((LineH.Y2 - LineH.Y1) ^ 2 + (LineH.X2 - LineH.X1) ^ 2)
Timer1.Enabled = True
'设置计时器的Interval属性值为1秒
Timer1.Interval = 1000
Call Timer1_Timer

End Sub

Private Sub Timer1_Timer()
 Dim s As Single, m As Single, h As Single
Label5.Caption = "现在是:" & Time
'取时间,秒,分,时.
s = Second(Time)
m = Minute(Time)
h = Hour(Time) + m / 60
'计算指针另一端的坐标
LineS.X2 = LineS.X1 + len_S * Sin(PI * s / 30) '秒针,分针转一周分为60等分.
LineS.Y2 = LineS.Y1 - len_S * Cos(PI * s / 30)
LineM.X2 = LineM.X1 + len_M * Sin(PI * m / 30)
LineM.Y2 = LineM.Y1 - len_M * Cos(PI * m / 30)
If h > 12 Then h = h - 12
LineH.X2 = LineH.X1 + len_H * Sin(PI * h / 6) '时针转一周分为12等分
LineH.Y2 = LineH.Y1 - len_H * Cos(PI * h / 6)

End Sub

⌨️ 快捷键说明

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