1

I have a problem: one of the forms in my project takes long time to load. Situation: With using debugger I go through code. When I reach row with Load frmTest (there is a specific form) it takes about 1.5 - 2 seconds to continue in Form_Load handler.

I tried to search for some documentation, but failed... well at least finding any information about what Load Sub does before Form Load event triggers.

So, how does the VB.Global.Load work?

VB6 IDE Object browser VB.Global

  • 1
    The biggest job it does it to initialize all the controls/activex components sited on the form (or anything in the global scope declared As New) so if you have any third party ones then that's something to investigate. – Alex K. Jun 7 at 10:36
  • 1
    As mentioned, controls and activex components will be instantiated and initialized. If there are a large number of controls, that could account for time. If any of the controls are data bound, time may be taken connecting to and reading from a database or other data source. – MarkL Jun 7 at 13:50
0

Assuming this is VB6 (never heard of 'VB.Global.Load' in that context), see Life Cycle of Visual Basic Forms

  • VB.Global.Load is the sub you use to load forms: Load Form1. At least this is the description when you load Load in object browser. The VB is the class library that contains static (I think) class Global which provides Sub Load – Mantas Daškevičius Jun 7 at 11:26
  • 1
    I stand corrected. I very rarely use the object browser, mainly because it often doesn't provide much information as you've found! – John Eason Jun 7 at 13:40
  • That's because you are supposed to press F1 for further help on the item. Object Browser has the binary definition and the Help topic ID. – Noodles Jun 8 at 22:25
0

There're so many things that can go wrong.

That's how I would analyze this case.

  1. Check if you have Form_Initialize method, if not - create it and check if delay's before or after this method's call.
  2. Check if you have any private fields on a form level. If there're heavy objects there they may be initialized before the form Load and it may take the time. Especially actual for the COM objects.
  3. If this happens for a single form only I would try to understand what's so special about this exact form and if needed remove everything to the ground to detect the problem.
  • Thanks for the advice but it is not really what I asked for. I actually already tried all of that and found those speed problems. But thanks any way. – Mantas Daškevičius Jun 15 at 16:30
0

Thanks @Alex K. for the answer:

The biggest job it does it to initialize all the controls/activex components sited on the form (or anything in the global scope declared As New) so if you have any third party ones then that's something to investigate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.