2017-04-23 37 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