Professional Documents
Culture Documents
VISUAL BASIC:
VISUAL BASIC is a programming environment from Microsoft in which a programmer uses a graphical user
interface (GUI) to choose and modify pre-selected sections of code written in BASIC programming Language.
IDE:
MDI:-
1. Byte
2. Integer
3. Long
4. Single
5. Double
6. Currency
7. Boolean
8. Date
9. Object
10. String
11. Variant
VARIABLE:
1. Variables are areas allocated by the computer memory to hold data.
2. The content of a variable changes now and then in a program.
Menu Bar:
1. This Menu Bar displays the commands that are required to build an application.
2. The main menu items have sub menu items that can be chosen when needed.
3. The toolbar in the menu bar provide quick access to the commonly used commands and a button in
the toolbar is clicked once to carry out the action represented by it.
Tool Bar:
1. The Toolbox contains a set of controls that are used to place on a Form at design time thereby
creating the user interface area.
2. Additional controls can be included in the toolbox by using the Components menu item on the
Project menu.
CONTROL DESCRIPTION
POINTER Provides a way to move and resize the
controls form
PICTURE BOX Displays icons/bitmaps and meta files. It
displays text or acts as a visual container
for other controls.
TEXTBOX Used to display message and enter text.
FRAME Serves as a visual and functional container
for controls
COMMAND BUTTON Used to carry out the specified action when
the user chooses it.
CHECKBOX Displays a True/False or Yes/No option.
OPTION BUTTION Option Button control which is a part of an
option group allows the user to select only
one option even it displays multiple choices.
LIST BOX Displays a list of items from which a user
can select one.
COMBO BOX Contains a Text-box and a List Box. This
allows the user to select an item from the
drop-down List Box, or to type in a
selection in the Text-box.
HSCROLLBAR AND VSCROLLBAR These controls allow the user to select a
value within the specified range of values
TIMER Executes the timer events at specified
intervals of time
DRIVELISTBOX Displays the valid disk drives and allows the
user to select one of them.
DIRLISTBOX Allows the user to select the directories and
paths, which are displayed.
FILELISTBOX Displays a set of files from which a user can
select the desired one.
SHAPE Used to add shape (rectangle, square or
circle) to a Form
LINE Used to draw straight line to the Form
IMAGE used to display images such as icons,
bitmaps and meta files. But less capability
than the Picture Box
DATA Enables the user to connect to an existing
database and display information from it.
OLE Used to link or embed an object, display and
manipulate data from other windows based
applications.
LABEL Displays a text that the user cannot modify or interact
with.
Project Explorer:-
1. Docked on the right side of the screen, just under the toolbar, is the Project Explorer window.
2. The Project Explorer as shown in in figure servers as a quick reference to the various elements of a
project namely form, classes and modules.
3. All of the object that makes up the application is packed in a project.
4. A simple project will typically contain one form, which is a window that is designed as part of a
program's interface.
5. It is possible to develop any number of forms for use in a program, although a program may consist
of a single form.
6. In addition to forms, the Project Explorer window also lists code modules and classes.
Properties Window:-
1. The Properties Window is docked under the Project Explorer window.
2. The Properties Window exposes the various characteristics of selected objects.
3. Each and every form in an application is considered an object.
4. Now, each object in Visual Basic has characteristics such as color and size.
5. Other characteristics not only affect the appearance of the object but the way it behaves too.
6. All these characteristics of an object are called its properties.
7. Thus, a form has properties and any controls placed on it will have properties too.
8. All of these properties are displayed in the Properties Window.
Object Browser:-
1. The Object Browser allows us to browse through the various properties, events and methods that are
made available to us.
2. It is accessed by selecting Object Browser from the View menu or pressing the key F2.
3. The left column of the Object Browser lists the objects and classes that are available in the projects
that are opened and the controls that have been referenced in them.
4. It is possible for us to scroll through the list and select the object or class that we wish to inspect.
5. After an object is picked up from the Classes list, we can see its members (properties, methods and
events) in the right column.
6. A property is represented by a small icon that has a hand holding a piece of paper.
7. Methods are denoted by little green blocks, while events are denoted by yellow lightning bolt icon.
A variable has a name and a value and stores values during program execution.
Declaring Variables :
1. To declare a variable use the Dim statement followed by the variables name, As
keyword, and its type.
2. In a program, variables must be declared in advance.
3. If the compiler is informed of all the variables and their types, it can produce the
most compact and efficient code.
4. When we declare a variable we are actually telling the compiler the type of data we
intend to store in each variable.
Variable initialization :
We can also initialize variables in the same line that declares them.
Example:
The following line declares an integer variable and initialize it to 35.
Dim minMarks As Integer 35
This statement is equal to the following two statements.
Dim minMarks As Integer
minMarks = 35
Variables are initialized when they are declared, according to their type.
Numeric variables are initialized to zero, string variables are initialized to a blank
string, and Object variables are initialized to nothing.
If the variable is declared with an initializer (as in Dim i As Integer 50) it is initialized to
the specified value.
Types of variables:
Visual Basic recognizes the following five categories of variables.
1. Numeric
2. String
3. Boolean
4. Date
5. Object
Numeric variables:
All programming languages provide a variety of numeric data types, including the
following:
Integers
Decimals
Single
Double
1. Decimal, Single and Double are the three basic data types for storing floating point
numbers.
2. The Short data type is the same as the integer data type .
3. The new Integer data type is the same as the long data type.
4. Long data type is new and can represent extremely large integer values.
Naming of variables:
Block-Level scope:
It is used in a If statement or while loop or for loop.
A block level scope is visible only in a block of vb code.
The i variable is not visible outside the block of the if..End If loop.
If we attempt to use it before the If statement, or after the End If statement, VB will throw
an exception.
Module-level scope:
Variables declared outside any procedure in a module are visible from within all
procedures in the same module, but they're invisible outside the module.
Setting variables from within many procedures can complicate the debugging of the
software program.
The period which a variable holds a value is called the lifetime of a variable.
Variables declared as Public exist for the lifetime of the software program.
Local variables, declared within procedures with the Dim or Private statement, are
alive as long as the procedure.
When the procedure ends, the local variables cease to exist and the allocated memory
is returned to the system.
When the same procedure is called again the local variables are recreated and
initialized.
If a procedure calls another procedure, its local variables retain their values while the
called procedure is running.
With the Static keyword we can force a local variable to preserve its value between
procedures.
We must declare the variables RunTotal and NumofItems outside the function so that their
values are preserved between calls.
We can also declare them in the function with the Static keyword,