gpt4 book ai didi

excel - 进度指示器,在vba中变得没有响应

转载 作者:行者123 更新时间:2023-12-02 10:42:44 27 4
gpt4 key购买 nike

我已经读完 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

有什么想法为什么会发生这种情况吗?

enter image description here

最佳答案

这已经困扰我一段时间了,你促使我寻找答案 - 谢谢。

实际上非常简单,只需将 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com