[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 407
  • Last Modified:

Difference of following ....

Can anybody tell me the difference between the following:

1) form1_terminate
    form1_unload

2) form1_initialize
    form1_load

3) set object1 = nothing
    object = NULL
0
lenzge
Asked:
lenzge
  • 2
1 Solution
 
DhaestCommented:
Load: Use the Form_Load event for initialisation. Initialisation means things you want to have ready before using the Form, such as fill up a combo box with data, assign initial values to certain variables.
When the program starts up, it runs the Sub Main from the Basic Module or load a Form of your choice. Use the Menu Command Project | Properties (Click Tab GENERAL) to select the start up Form or Sub Main:
While running the application, you can get the application out of sight by using the Hide method, and bring it back with the Show method. Hide/Show does not affect the status of the form at all because the form is already there.
You can remove the form completely from the memory by using the Unload method, then bring it back again with the Show method. This time the Show method implies a Load action plus the normal Show action (similar to the case Hide/Show), i.e. the Form is initialised by the Load action.
Sometime you want to do some initialisation on the controls of the form before presenting it to the world. In that case do a Load, do all the necessary initialisation then Show the form.
Note that while you are inside Sub Form_Load the Form is not yet existent. Therefore you cannot execute a Setfocus of a control of the form while that form is being loaded. One way to get around it is to Enable a Timer to schedule that Timer to run in 300ms (i.e. delaying the SetFocus action until the Form becomes existent).
If you want to define the start up position of a Form (i.e. where the Form appears on the screen when it first shows up at run-time) use the Form Layout Window to do that.
Activate: use Form_Activate to update certain things each time the form is revisited. It’s similar to initialisation in Form_Load, except that Form_Load is called only once at loading whereas Form_Activate is called every time the Form becomes active (i.e. regaining the focus).
Unload ' use to tidy up loose ends before leaving. Sometimes, it’s better to use Form_QueryUnload as it returns UnloadMode which tells you how the unload was initiated (i.e. by user, by other program etc..). Then you can decide to stop the Form unload process by setting Cancel to True.
 
Left, Top: X,Y coordinates of Form relative to the Top Left corner of the screen. You can set these values in Form_Load.
Width, Height : Size of Form including Border. Use ScaleWidth and ScaleHeight to refer to the form size without border.
WindowState : You use it to indicate the start up state of the Form. It’s either Normal (as you had it at design time), Minimised (Iconised) or Maximised (take the whole screen).
A form can be run in either Modeless or Modal mode.
0
 
BrianGEFF719Commented:
I tried to explain the best I could

1) form1_terminate
    form1_unload

    Basically Terminate refers to the program, unload can be called if another program Unloads the object Form1.


2) form1_initialize
    form1_load

    Form1 initalize is only called when the form is initalized, so if another form Loads the Object Form1, form1_load will be called.

3) set object1 = nothing
    object = NULL

   Set Object = nothing is basically clearing the memory
   object = NULL <--- NOT EVEN VALID VB Code
   
0
 
lenzgeAuthor Commented:
Sorry, clarification for no. 3:

i) set object_abc = nothing

ii) if (object_abc = NULL) then
       (action code's here)
    end if

When the second case will return a true value?
0
 
lenzgeAuthor Commented:
Oops, I made a mistake on #3 and now I know what's wrong about it now. Thanks to all of you.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now