Sunday, September 12, 2010

visual basic features and programming options

Visual Basic is a high level programming language evolved from the earlier DOS version called BASIC. [Beginners' All-purpose Symbolic Instruction Code], programming language from Microsoft specialized for developing Windows applications.
Visual Basic is Easy to learn Programming language. WithVisual Basic you can develop Windows based applications and games. When first released in 1991, it was similar toMicrosoft’s QuickBASIC, With its visual user interface development tools.
Visual Basic became very popular by the mid-1990s. Visual Basic is much more easier to learn than other language (like Visual C++), and yet it’s powerful programming language.
In VISUAL BASIC, programming is done in a graphical environment. Because users may click on a certain object randomly, so each object has to be programmed independently to be able to response to those actions (events).

History of Visual Basic


VISUAL BASIC is evolved from the earlier DOS version called BASIC. BASIC means “Beginners Allpurpose Symbolic Instruction Code”. It has been around for more than 35 years. BASIC was further developed as Visual Basic to make it compatible with today’s environment. Microsoft created the enhanced version of BASIC, called visual basic.
The bottom line of the enhancement is that VISUAL BASIC can create Windows programs whereas BASIC could only create DOS programs. It means that BASIC programming is done in a text-only environment and VISUAL BASIC programming is done in a graphical environment.

Graphical User Interface


VISUAL BASIC makes use of GRAPHICAL USER INTERFACE (GUI) for creating robust and powerful applications.
A simple GUI looks like this:

GUI given above shows graphical interaction between user and system. That is why a GUI is an effective mean of making your application user friendly and is the key to creating successful applications.
GUI becomes very popular because users can easily identify things with the help of graphics. The main advantage of using GUI is that user can interact with application using common sense. Even a laymen user can learn GUI applications easily.


Visual Basic Integrated Development Environment(IDE)



VISUAL BASIC IDE (INTEGRATED DEVELOPMENT ENVIRONMENT ) is the environment in which its program are written and executed. IDE stands for Integrated Development Environment. IDE is a term commonly used to describe the interface and environment for creating your application. It is called IDE because you can access all of the development tools that you need for developing an application.



VISUAL BASIC IDE contains different components. These components are:

Tool Bar
It provides quick access to commonly used commands in the programming environment. You click a button on the toolbar to carry out the action represented by that button. The Standard toolbar is displayed when you start Visual Basic. You can change toolbar settings by selecting Toolbars option form View menu.

Toolbar can be removed from beneath of the menu bar, if you click on the Left Edge and drag it away from the menu bar.

Form Designer

Form objects are the basic building blocks of Visual Basic application.It is the actual window with which a user interacts at the start of application. Forms have their own properties, events, and methods with which you can control their appearance and behavior. Properties, events, and methods of a form will be explained further in tutorial.


The Form Window is central to developing Visual Basic applications.It is the window where you draw your application

Tool Box


The Toolbox is a long box with many different icons on it. It is the selection menu for controls (objects) used in your application. To work in Visual Basic we’ve to know about its tools so that we can make different forms, projects and how to edit them. we’ll learn all these things in this module.




Property Window

Properties Window is used to establish initial property values for objects (Like Form etc.). The drop-down box at the top of the window lists all objects in the current form.Two views are available: Alphabetic and Categorized. Given box shows the available properties for currently selected object:


If you are not getting property window on IDE then click on Project Explorer option from view menu. Or, Use key F4 or Alt+V+W for displaying property window.


Project Explorer

Project Explorer Window displays a list of all forms used in making up your application. You can also obtain a view of the Form or Code windows (window containing the actual Basic coding) from Project Explorer window.
If you are not viewing Project Explorer on IDE then click on Project Explorer option from the view menu. OR, Use Ctrl+R for displaying Project Explorer Window.



Menu Bar

It is a horizontal strip that appears across the top of the screen and contains the names ofmenus.Menu Bar lists the menus that you can use in the active window.


You can modify the menu bar using the Commands tab of the Customize dialog box. For that go to the View menu ,then select Toolbars. Now Click on the customize option. OR, You can use key combination Alt+V+T+C for that.

A window will appear like the figure given below:


A list of options will be displayed .A user can make a selection in order to perform a selected action. Suppose if you want to animate menu options then click on the options in above figure. OR, Use key combination Alt+V+T+C+O for animation.



Form Layout Window

Form Layout Window shows where (upon program execution) your form will be displayed relative to your monitor’s screen:


Click on to the Form Layout window option from view menu for displaying above window. OR, Use Key Combination Alt+V+F for that. It allows you to visually position your forms .
All forms will be displayed whenyou place your cursor over a form. Press the mouse button,and drag it where you want the position of your form.

Data Types

Application Of Visual Basic
Visual Basic is the most sophisticated tool for developing commercial applications .Various information system are implementing in VISUAL BASIC today,these are as follows:
Various information system are implementing in VISUAL BASIC today,these are as follows:
MIS(Management Information System),
EIS(employee Information System),
Inventory control,
ERP(Enterprise Resource Planning),
Web application,
Library Management System Etc.
VISUAL BASIC is mostly used in application programming. VISUAL BASIC provides easy to use connectivity with database that is why most of database related software are being developed in VISUAL BASIC today.
A simple VISUAL BASIC application works like given in fig:

Visual Basic supports different types of data types according to the needs of program or application
You can say that attribute of a variable that determines what kind of data it can hold is known as Datatype.
By Default Visual Basic supports the variant data type.Declaring a variable variant indicates that it can support all types of data types.Mainly Visual Basic supports the following datatypes:

Table of Data Types

Data Types Storage (in bytes) Prefix Example
Byte 8 Byt bytVar
Boolean 1 Bln blnNum
Integer 2 int intCount
Long; 4 lng lngNumbers
Single 4 sng sngAverage
Double 8 dbl dblMarks
Date 8 dte dteNext
Object 4 obj ObjMywork Avgs
String According to the length of string str strNames
Variant 16 vnt vntTotal

Variables


Any programming language requires to store values temporarily for different purposes like calculations Adding, multiplying etc.Visual Basic gives the need for variables. You can think of variable, a place in memory of computer for an unknown value.
For example when you call someone, then you call him /her by name, like that every variable has name.
Variable name is the word which you use to refer to the values that the variable contains.

VARIABLES:- Naming convention

There are different rules for assigning names to variables ,these are as follows:

A variable name must begin with a letter.

For example:
6date – Invalid variable name
date6 – valid name

Two variables must not contain the same name.

It can not contain a dot or space.

For example:
Num2 – Valid variable name
Num.2 – Not Valid
Num 2 – Not Valid

A variable name must not exceed 255 chracters.

A variable name must not contain any special characters like %, $ , * , & ,! ,@ etc.

For example:
@num, num$r are not valid variable names.

Variable:-Declaring

The term declaring a variable means that the memory is allocated .This memory will be referred by a name decided by the programmer.The specific data type decides the amount of memory allocated.
You can declare a variable with a Dim statement by giving a name for the variableaccording to rules of naming conventions.

Syntax: Dim variablename as Datatype

Example: Dim a as integer
In above example ‘a’ is variable name and integer is the data type.

Rules for declaring variables:
(i) Declaring a variable using the word Public makes it available throughout the program.
(ii) Declaring a variable using the word Static keeps it’s value preserve until a procedure ends.
(iii) Declaring a variable in the declaration section of the form makes it available to all procedures in that module.

For example:
Let us consider the variable ‘var1 ‘. An integer variable ‘var1′ is declared. At the same time memory is allocated for the variable.
The variable is given value 20 during the running state of the program. This value is stored in the given memory location.

This process is shown in figure:



Constants

Constants as the name suggests , never change during the execution of program.They remain same throughout the program execution.
When the user wants a value that never changes, a constant can be declared and created.

The syntax for declaring a constant is:

(Public|Private) Const constantname (As type) = expression

The const statement can be declared as:

Public const pie as single=3.14

Modules


A module is a set of functions and a set of data members.Code in Visual Basic is stored in the form of Modules. Collection of general procedures, variable declarations, and constant definitions used by application is known as module.

Mainly Visual Basic supports 3 types of modules:

(1) Form module
(2) Standard Module
(3) Class Module

Form module

Form modules provide the user interface to the application. They contain controls and properties of the forms. They have the extension .FRM.
Their declaration is private by default, therefore each form has a single form module associated with it.

Standard Module

As we go further in developing the application than there may be common code for execution of several form.
For avoiding the duplication of code, a separate module containing the code is implemented.
This is called as standard module. A standard module (.BAS) contains only code. It contains extension .BAS.

Class Module

A class module (.CLS) is used to create objects (forms etc.). It can be called from procedures within your application.
Class modules (.CLS filename Extension) are writing code in class modules can create the building blocks of object oriented programming in Visual Basic.New objects.

Each module contains different elements, these are:

Declaration
It includes constant and procedures.

Procedures
Sub function or property procedures that contain pieces of code that can be executed as a unit. It avoids code repetition.

No comments:

Post a Comment