Link to home
Start Free TrialLog in
Avatar of sopheak
sopheak

asked on

Proper order

I have 2 forms, frmMain and frmSplash.

I want to have the Splash screen up first while the Main form is loading in the background.

This my code below in the Splash form....

-------------------
Option Explicit
Private Sub Pause(interval)
Dim Current
Current = Timer
Do While Timer - Current < Val(interval)
DoEvents
Loop
End Sub

Private Sub Form_Load()
Load FrmMain
   
Call Pause(5)
   
FrmMain.Show

End Sub

------------------------------
 
This code seems to work but, it seems to take a long time to load the splash screen.  If I were to take the Private Sub Form_Load() out, the splash screen loads a  lot quicker.

Any suggestions is appreciated
Avatar of AzraSound
AzraSound
Flag of United States of America image

try loading your splash form in your Sub Main function of the module

Sub Main()
    frmSplash.Show
End Sub


Move your code to the Form Activate sub and be sure to unload your splash form.

e.g.

Private Sub Form_Activate()
Load FrmMain
     
Call Pause(5)
     
FrmMain.Show

Unload FrmSplash
End Sub
ASKER CERTIFIED SOLUTION
Avatar of AzraSound
AzraSound
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of timpeters
timpeters

You could also put your code in the Activate event of the splash form.  This wouldn't be a problem because the Splash form would be unloaded anyway after your main form is loaded.  Therefore, the Activate event would never be called again to cause a problem.
Avatar of sopheak

ASKER

Thanks, AzraSound.  I removed the load frmMain and it works great.