[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now


Difference of following ....

Posted on 2004-04-29
Medium Priority
Last Modified: 2012-06-21
Can anybody tell me the difference between the following:

1) form1_terminate

2) form1_initialize

3) set object1 = nothing
    object = NULL
Question by:lenzge
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 53

Expert Comment

ID: 10956481
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.
LVL 19

Accepted Solution

BrianGEFF719 earned 200 total points
ID: 10956997
I tried to explain the best I could

1) form1_terminate

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

2) form1_initialize

    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

Author Comment

ID: 10974849
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?

Author Comment

ID: 10993568
Oops, I made a mistake on #3 and now I know what's wrong about it now. Thanks to all of you.

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question