You should not use this:
Code:
Do While LicenseDoneFlag = False
DoEvents
Loop
as it will tie up the processor and stop other events from running.
If you really need to wait for "License" to return you should set up a timer that checks periodically for the flag, and only load the main layout when the flag is set.
Also you may want to ony call "License" when "FirstTime" is true.