我已经读完 stackoverflow关于如何使用进度条。
它工作正常,但在 6% 后,我的 235 数组中的第 14 行显示没有响应,并且一直这样做,直到循环完成。
所以我正在 vbmodeless 运行它:
ProgressBar.Show vbModeless
ProgressBar.Label_WhatsGoingOn.Caption = "Reading data from database.."
projectNumber = "32966"
docOutArray = Post.helpRequest("xdnjgjrdin.asp?Dok4=" & projectNumber)
If CPearson.IsArrayEmpty(docOutArray) Then
MsgBox "No document registered in database!"
End If
ProgressBar.Label_WhatsGoingOn.Caption = "Creating Docout.."
Set doc_ = NEwDocOut.createDocOutDocument(projectNumber)
numOfRows = UBound(docOutArray, 1)
For i = LBound(docOutArray, 1) To numOfRows
ProgressBar.Label_WhatsGoingOn.Caption = "Creating Row.."
sPercentage = (i / numOfRows) * 100
ProgressBar.progress (sPercentage)
我的进度条代码:
Private Sub UserForm_Initialize()
Me.Text.Caption = "0% Completed"
End Sub
Public Sub progress(pctCompl As Single)
Me.Text.Caption = Format(pctCompl, "##") & "% Completed"
Me.Bar.Width = pctCompl * 2
Me.Repaint
DoEvents
End Sub
有什么想法为什么会发生这种情况吗?
最佳答案
这已经困扰我一段时间了,你促使我寻找答案 - 谢谢。
实际上非常简单,只需将 DoEvents
放入循环中(根据您的情况):
For i = LBound(docOutArray, 1) To numOfRows
'Add this line here:
DoEvents
ProgressBar.Label_WhatsGoingOn.Caption = "Creating Row.."
sPercentage = (i / numOfRows) * 100
ProgressBar.progress (sPercentage)
关于excel - 进度指示器,在vba中变得没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39915562/