Tuesday, September 1, 2020

Modules in VB:

Form Module: The form that you can see on the screen is a representation of the properties that define its appearance and behavior of a component place on it.  For each form in an application there is a related form module that contains its code.

Each form module contains event procedure which is a section of the code where you place the instruction that will execute in response to specific event.  Form can contain controls.  For each control on the form there is a corresponding state of event procedure in the form module.  In addition to the event procedure, form module can contain the general procedure that is executed in response to a call from any event procedure.

To add a new form to the project, from the project menu select the option “Add Form”, selected type of the form and click on open button.

Standard Module:

This standard module can be used to declare the global data and the global methods which can be accessed anywhere in the project or an application.

Code that isn't related to a specific form control can be place in a different type of module, standard module (.BAS)

To add a standard module into the project, from the project menu select an option “Add Module”, and click on “open” button

Class Module:

A class module is used to create object that can be called from procedure within your application.  Where as a standard module contain only code, a class module contain both code and data.

The members in the class module can only be accessed through its object.  One class can be defining in one class module.

To add a new Class module to the project, from the project menu select the option “Add Class Module”, select the type of the class and click on open button.

By default, your project contains a single form module.  User can add additional form, class and standard module, as needed.


No comments:

Post a Comment