opfzi.blogg.se

Vb6 form events sequence
Vb6 form events sequence





vb6 form events sequence

Fortunately MSForms checks for a real value change, saving us work. Note that TextBoxB wàs modified by the event handler (set to vbnullstring), however the Change event was not raised. Type some text in Textboxes A and C and set the focus on Textbox B. We shall see that this is not always the case. From the MSForms help: “The BeforeUpdate event occurs before the AfterUpdate and Exit events for the control and before the Enter event for the next control that receives focus”. Keep the troika BeforeUpdate – AfterUpdate – Exit in mind. Type something in TextboxA and then click on TextBox B: Note that the TextBox control has no Click event. When you switch from TextBoxA to TextBoxB by a mouse click these events are fired: With respect to the hide command: keep in mind that this ends the modal state of the userform, and that code execution continues after the show command. In case you need to do some finalization each time the form deactivates you need to define the exit-points yourself and perform the exit code “manually”. This event is only raised when you switch to another userform, either from a modal form to another modal child form, or from a modeless form to another modeless form. unfortunately, the UserForm_Deactivate event is in simple userforms of no use at all.the UserForm_Activate event is very useful in case you need to do some initialization each time the userform returns from an idle state (in contrast to only once initialization in the Userform_Initialize handler).Showing the form again also fires one event: Hiding and re-Showing the Form: deactivate and activateĪ click on the Hide button fires one event: Except for the missing deactivate no surprises.

vb6 form events sequence

The Unload Me command in the ButtonUnload_Click handler fires the Quer圜lose and Terminate events. If we close the form with a click on the Unload button the trace list becomes: Indeed, there is no Deactivate event fired. Click the window Close button immediately after startup and the trace list results in:

vb6 form events sequence

So, if we unload or hide the form we would expect a deactivate event to be raised. Quote from the Visual Basic Language Reference: “The Deactivate event occurs when an object is no longer the active window”. The Forms object library seems to do the opposite: first activate/enter the low level control, then activate the form. Notice the difference with the workbook event model, where activation is top-down: Workbook – Window – Worksheet. The second event only fires if the form contains a control that can take the focus and is enabled to do so. Showing the form from an unloaded state results in: See Debug and trace in VBA for details on this debug technique. Most of these event handlers contain only two lines of code to create a trace list in the VBE Immediate Window. In the code module of the form the most relevant events are defined.







Vb6 form events sequence