📄 form3.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form Form3
Caption = "Form3"
ClientHeight = 6720
ClientLeft = 60
ClientTop = 345
ClientWidth = 9225
LinkTopic = "Form3"
ScaleHeight = 6720
ScaleWidth = 9225
StartUpPosition = 3 '窗口缺省
Begin VB.Timer Timer1
Left = 6480
Top = 3960
End
Begin VB.Timer TmrTimer
Left = 7560
Top = 2400
End
Begin VB.CommandButton Cmdbegin
Caption = "Command1"
Height = 735
Left = 3360
TabIndex = 1
Top = 4560
Width = 1215
End
Begin MSComctlLib.ProgressBar prgBar1
Height = 255
Left = 840
TabIndex = 0
Top = 2640
Width = 3855
_ExtentX = 6800
_ExtentY = 450
_Version = 393216
Appearance = 1
End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Form_Load() '缩小方块的大小直到其所表示的进度增加量与实际进度值达到最接近的匹配程度,
'应使 ProgressBar 控件的宽度至少是其长度的 13 倍。
'块数量越多,控件就越能精确地描述操作进度。
prgBar1.Visible = False
TmrTimer.Interval = 1000 '将 Interval 设置为 1000(毫秒,即 1 秒)
prgBar1.Max = 20 'Timer 将运行 10 秒钟。
'Max 属性的值应为 Timer 停止之前,希望它持续计时的时间。
prgBar1.Min = 1 '同时为准确地反映经过的时间,ProgressBar 的 Min 属性应设置为 1。
End Sub
Private Sub cmdBegin_Click()
prgBar1.Visible = True
TmrTimer.Enabled = True
End Sub
Private Sub tmrTimer_Timer()
Static intTime '声明静态变量。
'第一次执行时,该变量应为空值。
'如果它是空变量,将其设置为 1。
If IsEmpty(intTime) Then intTime = 1 '由于不希望从 0 开始计数,
'所以使用 IsEmpty 函数判断后将该变量设置为 1
prgBar1.Value = intTime '更新 ProgressBar。
If intTime = prgBar1.Max Then
Timer1.Enabled = False '
prgBar1.Visible = False
intTime = 1
prgBar1.Value = prgBar1.Min
Else
intTime = intTime + 1
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -