我的代码工作正常,直到我想卸载新生成的表单。
我有2个计时器:: 1用于加载启动表单,1用于卸载启动表单。
Option Explicit
Private frmSplash As Form
Private Sub splashForm()
Set frmSplash = New myForm
With frmSplash
.Width = 4000
.Height = 3000
.Caption = "Splash"
End With
frmSplash.Show vbModal
unloadSplash.Enabled = True
End Sub
Private Sub Form_Activate()
Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
splashTimer.Enabled = True
End Sub
Private Sub splashTimer_Timer()
splashForm
End Sub
Private Sub unloadSplash_Timer()
'MsgBox "Am I alive ?"
Unload frmSplash
Set frmSplash = Nothing
unloadSplash.Enabled = False
splashTimer.Enabled = False
End Sub
在unloadSplash_Timer
...
splashTimer.Enabled = True
似乎没有启用
答案 0 :(得分:3)
" vbModal"在该命令中停止代码。您必须将卸载启动窗体的计时器移动到启动窗体中。
事件顺序是:
-> sub Form_Activate
-> sub splashTimer_Timer
-> sub splashForm
---> frmSplash.Show vbModal (here the code stop until your form is not unload)
/* If you close manualy the "frmSplash" the the timer "unloadSplash" start. */
答案 1 :(得分:1)
您可以在启动表格中移动计时器并从那里执行,如果您愿意,只能有一次。所以在坚果壳中: