excel VBA 实现窗体模拟显示进度条

来源:互联网 时间:2016-01-03

Sub gogo()

'*****************************************************************

'此宏模拟显示进度条,放在模块中

'窗体UserForm1中有label1,label2.label3.label4

'label1,2,3重叠在一起

'label1为底,label2为进度条,label3显示百分比,label4显示文字说明

'长度都为200,高度为15

'底色为灰,进度条深蓝,百分比字体颜色黄色

'Vincent整理2010.12

'*****************************************************************

Dim i, j As Integer, k As String, arr As Variant

arr = Array(">", ">>", ">>>", ">>>>", ">>>>>", ">>>>>>", ">>>>>>>", ">>>>>>>>", ">>>>>>>>>")

k = "数据正在处理中"

j = 0

UserForm1.Show 0

For i = 1 To 100 Step 0.002

If j > UBound(arr) Then j = 0

UserForm1.Label4.Caption = k & arr(j)

j = j + 1

UserForm1.Label2.Width = i / 100 * 200

UserForm1.Label3.Caption = Format(i, "0") & "%"

DoEvents

Next i

Unload UserForm1

MsgBox "数据处理完毕!程序退出!", 64, "系统提示"

End Sub

Sub gogogo()

'*****************************************************************

'此宏模拟显示进度条,放在模块中

'窗体UserForm1中有label1,label2.label3.label4

'label1,2,3重叠在一起

'label1为底,label2为进度条,label3显示百分比,label4显示文字说明

'长度都为200,高度为15

'底色为灰,进度条深蓝,百分比字体颜色黄色

'*****************************************************************

Dim i, j As Integer, k As String

j = 1

UserForm1.Show 0

For i = 1 To 100 Step 0.002

If j > 100 Then j = 1

If j = 1 Then

k = "数据正在处理中" & ">"

ElseIf j Mod 10 = 0 Then

k = k & ">"

End If

UserForm1.Label4.Caption = k

j = j + 1

UserForm1.Label2.Width = i / 100 * 200

UserForm1.Label3.Caption = Format(i, "0") & "%"

DoEvents

Next i

Unload UserForm1

MsgBox "数据处理完毕!程序退出!", 64, "系统提示"

End Sub

相关阅读:
Top