我创建了一个处理application.wait的状态栏。从某种意义上说,这非常有效。但是,我希望能够在处理其他工作表时更新状态栏。我无法找到合适的方法。以下是我到目前为止的情况。
Private i As Integer
Private newHour
Private newMinute
Private newSecond
Private waitTime
Private Sub UserForm_Activate()
For i = 1 To 10
UserForm1.Label1.Width = UserForm1.Label1.Width + 24
Application.Calculate
If Application.CalculationState = xlDone Then
newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime
End If
Next
UserForm1.Hide
End Sub
注意:由于某些奇怪的原因,我可以让标签不断更新的唯一方法是使用Application.Calculate。否则,它将等待整整10秒,然后状态栏将在隐藏用户窗体之前达到最大扩展名。
答案 0 :(得分:1)
使用此延迟功能代替Application.Wait
Private Sub delay(seconds As Long)
Dim endTime As Date
endTime = DateAdd("s", seconds, Now())
Do While Now() < endTime
DoEvents
Loop
End Sub