📄 例6-7.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "计时报警"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdStart
Caption = "开始"
Height = 495
Left = 1680
TabIndex = 1
Top = 2280
Width = 1215
End
Begin VB.Timer Timer1
Left = 240
Top = 120
End
Begin VB.Label lblTime
Alignment = 2 'Center
BeginProperty Font
Name = "宋体"
Size = 26.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 855
Left = 480
TabIndex = 0
Top = 720
Width = 3615
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 start As Boolean
'命令按钮的单击事件
Private Sub cmdStart_Click()
start = True '开始计时
End Sub
'初始化窗体中各控件
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 1000 '时钟控件的计时间隔为1000毫秒
start = False
lblTime.Caption = Time()
End Sub
'时钟控件的计时事件(每隔1000毫秒触发一次)
Private Sub Timer1_Timer()
Static count As Integer '声明静态变量count用于计时
If start Then count = count + 1 '每执行一次Timer事件过程(即每隔1秒),count的值加1
If count >= 10 Then
End '到达10秒终止程序
Else
lblTime.Caption = Time() '未到10秒则显示当前时间
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -