欢迎光临
我们一直在努力

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

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

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
赞(0) 打赏
分享到: 更多 (0)

轻博客

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏