When I debug the app with F5, Form_Load and Form_Activate get called just fine.
However, when I step through the code with F8, Form_Activate doesn't get called. :confused:
I load my form with Form2.Show
Printable View
When I debug the app with F5, Form_Load and Form_Activate get called just fine.
However, when I step through the code with F8, Form_Activate doesn't get called. :confused:
I load my form with Form2.Show
don't put any break points in your Form_Load, only in Form_Active.
Yes, you are right.Quote:
Originally Posted by agmorgan
For everyone else, try this experiment.
Open up a new standard exe project and add a second form to the default Form1.
One Form2, add the following code:On Form1 put a command button with Form2.Show in its click event; run it; click on Command1. You will see all three message boxes in the following order: Initalize - Load - ActivateVB Code:
Private Sub Form_Activate() MsgBox "Activate" End Sub Private Sub Form_Initialize() MsgBox "Initialize" End Sub Private Sub Form_Load() MsgBox "Load" End Sub
Now, on Form2, but a break on Initialize, and "walk" through the process. After the messageboxs for Initialize and Load appear, you will be taken to the "End Sub" of Command1_Click on Form1, and you won't see the messagebox for Activate on Form2.
The Activate event ONLY fires when the Form is the Active Window. It will not be the Active Window when you step through the code because the focus will return to the calling form. When you do not step through it, and allow the form to load normally, form2 will become the active window thus firing the Activate event.