Form modules (.FRM file name extension) are the foundation of most Visual Basic applications. Inside form module, you can define the following:
1. event procedures
The code that you write in a form module is specific to the particular application to which the form belongs; it might also reference to other forms or objects within that application.
You can see all the form events in the drop down list of Form code view.
When a form is loaded into memory, the form is hidden. It will not be shown to the user. You still need to show the form to the user. Form has several events that are triggered at certain state of the form depending on users' activity and the code that you provide. Several form events that you may need to consider are as follow:
Other evets are explained in Event Procedure of this tutorial.
General procedures are sub procedure and functions. It does not need to follow any predefined name as events procedure. You can create your own general procedure with more meaningful name.
General declaration is located at the top of the form code. This is the place where you put the declaration of your variables, constants, and types
To understand how it works, let us try a trivia project.
1. Start VB with Standard Exe project. You will get one form
2. In the form, do double click to see the code view
3. In the general declaration section copy and paste the following code
4. In the Project window, do right-click. Select Add then Form.Now you have two forms (Form1 and Form2).
5. Double click Form2 from the project window and double click the form to get code view.
6. In the general declaration section of Form2, copy and paste the following code
7. Run the program (F5) and you will see the sequence of events that VB performs. Once you get form1, click on the form to get form2.
Note: you can download the file of this example from here.
Preferable reference for this tutorial is
Teknomo, Kardi. Visual Basic Tutorial . http:\\people.revoledu.com\kardi\ tutorial\VB