制作带百分数的进度条控件的方法

来源:百度知道 编辑:UC知道 时间:2024/06/30 07:43:32
我想做一个带百分数显示的进度条,百分数在进度条中央,百分数与进度条重叠的部分自动变色。
要怎么实现?
给网站地址5分,给完整代码和步骤的给30分。

给你一个实现的思路,新建一个工程,放二个picturebox,二个label控件,添加代码:
Option Explicit

Private Sub TGauge(ByVal MaxValue As Long, Optional MinValue As Long)

Dim i As Long
Dim X As Single

'通过调整Picture2的width来模拟进度
With Picture2
X = .Width / MaxValue
.Width = MinValue
.Visible = True
End With

For i = MinValue To MaxValue
DoEvents
Picture2.Width = i * X
Label1.Caption = Format(i / MaxValue, "0%")
Label2.Caption = Label1.Caption
Next

End Sub

'单击窗体
Private Sub Form_Click()
TGauge 100000
End Sub

Private Sub Form_Load()
Me.Width = 6000
Me.Height = 2000

'Picture1是主容器
With Picture1
'白色背景
.BackColor = &HFFFFFF
'字体设置关系到label的定位,必须
.FontName