VB Lecture Notes - Forms
Objective #1: Use forms appropriately.
- A form is a basic building block of a Visual Basic project. Eventually, you'll be creating projects that consist of many forms. You'll also learn how forms can be
reused to save programming time and to give more consistency to a large project.
- Each form is really a class which we will study in more detail later. Usually, a class consists of many methods. Some methods are related to user
events such as click and keypress.
- A form has number of useful properties including the Text property. It is best to set the Text property
of a form to an appropriate phrase. The form's Text property appears in the blue title bar at the top of the form.
- The first default form of a VB project is often saved with the file name of Form1.vb. The class that goes along with this form is also named Form1.
For now in this VB course, it is not recommended that you change the this file name or that you rename the class even though it does not begin with the conventional form prefix frm.
- You can think of a form as having two basic parts, its interface and its code. The interface is what the user will see when he/she executes the program. The code
is the behind-the-scenes part of the form that contains the crucial logic and code that makes the form work that way the programmer intends it to work.
- A form and the objects on a form are measured in pixels. The size of the pixels on your monitor depend on your computer's screen resolution settings. Popular screen
resolution settings are 640 pixels by 480 pixels, 800 pixels by 600 pixels, or 1024 pixels by 724 pixels where the first number is the width of the screen and the second measurement is the height of
the screen. Larger numbers of pixels in the resolution means the screen looks sharper with more detail. For now in this course, it is not recommended that you resize a form to make it fill up more
of the computer screen.
- The Size property of a form is used to determine its size. Actually, it is the two subproperties, Height and Width,
of the Size property that determine the size of the form. The Location property of a form is used with its two subproperties, X and Y,
to determine the location of the upper-left corner of the form on the screen.
- The Load method of a form appears in the code window when you double-click anywhere on the interface of the form.
Any code typed into the form's Load method executes as soon as the form is loaded. The default form of your project loads as soon as you (or anyone else) execute your
project.