Internet上有很多教程。但是我找不到合适的东西。有什么方法可以在加载时制作动画点吗?
这个想法是在用户窗体上制作一个动画点.....
的循环,这样它们将一个接一个地出现,然后在一定数量的点之后重新开始。
所以我在Label1上输入了一个点,并在一定的时间标准后将其向左移动?
我当前的UserForm代码:
Private Sub UserForm_Initialize()
HideTitleBar.HideTitleBar Me
Call loadingdots
End Sub
Private Sub Workbook_Open()
的代码:
Loading.Show (vbModeless)
Dim RngCom As Range
Dim RngTurb As Range
Dim RngGen As Range
Application.Wait (Now + TimeValue("00:00:06"))
ThisWorkbook.Worksheets("MAIN").ScrollArea = "$A$1:$BL$45"
Application.DisplayFormulaBar = False
ActiveWindow.DisplayHeadings = False
ActiveWindow.DisplayGridlines = False
etc...
Unload Loading
'Application.ScreenUpdating = True
End Sub
答案 0 :(得分:2)
最优雅的解决方案可能是OnTime method。
在UF内放置一个标签,然后删除标题。接下来,在常规模块(而不是UF的常规模块)中,放置以下子例程:
'this function ensures the self-activating sub will stop if the UF has been closed
Public Function IsLoaded(form As String) As Boolean
Dim frm As Object
For Each frm In VBA.UserForms
If frm.Name = form Then
IsLoaded = True
Exit Function
End If
Next frm
IsLoaded = False
End Function
Public Sub loadingdots()
If IsLoaded("UserForm1") = True Then
If Len(UserForm1.Label1.Caption = 4 Then
UserForm1.Label1.Caption = "."
Else
UserForm1.Label1.Caption = UserForm1.Label1.Caption & "."
End If
Application.OnTime Now + TimeValue("00:00:01"), "loadingdots"
End If
End Sub
接下来,当UF初始化时,调用自激活子
Private Sub UserForm_Initialize()
Call loadingdots
End Sub
不要忘记将对UF的引用更改为正确的名称。