2017-04-23 46 views
2

我的代碼正常工作,直到我想卸載新生成的表單。視覺基本6 ::卸載與計時器的飛濺形式

我有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_TimersplashTimer.Enabled = True後未啓用...

+0

見的解決方案#2這裏https://stackoverflow.com/questions/43565625/visual-basic-6-unload-dynamically-created-form –

+0

的可能的複製[Visual Basic 6的::卸貨動態創建表格] (http://stackoverflow.com/questions/43565625/visual-basic-6-unload-dynamically-created-form) –

回答

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. */ 
+0

謝謝soooooooooooo多!!! :D – GoPro

+0

@GoPro很高興:) – Baro

1

您可以在飛濺的形式將你的計時器,並從那裏執行它,只有單一的時間,如果你想。因此,在一個果殼:

  • 應用開始>顯示在負載
  • 閃屏閃屏>定時器開始(指定的時間間隔 - 蜱)
  • 定時器Tick事件>關閉閃屏>加載主要形式。
+0

謝謝你! :d – GoPro