Docstoc

Programming with Visual Basic

Document Sample
Programming with Visual Basic Powered By Docstoc
					VISUAL
BASIC


   BY
  MALIK
                    TABLE OF CONTENTS
Visual Programming:-
   Low level and High level
   Procedure Oriented and Event Oriented
   Low visual and high visual Language
   Interoperated and complied Language
   History of Visual Basic
    Visual Basic IDE
   Student Exe Project
   Visual Components of Visual Basic IDE
   Tool Box
   Manu Bar
   Icon Toolbar
   Features of Objects
   Objects Properties
   Some Common Object Properties
   Object Methods
   Object Events
   Events Triggered by the Mouse
   Events Triggered by the Keyboard
   Event Procedure
   Changing Object Properties at Run Time
   Adding comments
   Concepts of Focus
   Exercises
Visual Basic Project
   Naming a project
   Saving a project
   Running a project
   Complied applications
   Compile to P-Code
   Compile Native Code
   Making Executable File
   Debugging
   Correcting System Errors
   Correcting Run Time Errors
   Correcting Logic Errors
   Be bugging Object
   Exercises
Working with Forms
       Basic component of Forms
       Changing Forms Properties
       Formatting Control on Forms
       Form Events
     Form Methods
     Adding Manu to Form
     Multiple Form Visual Basic Applications
     Accessing Information on Form
     Visual Basic Multiple Documents Interface(MDI)
     Exercises
Visual Basic Programming
     Data and Data Types
     Variables
     Type of Variables
     String type Variables
     Numeric Type Variables
     Special Variables
     Scope of Variables
     Lifetime of Variables
     Constants
     Assignments Statement
     Expressions
     Arithmetic Expressions
     Hierarchy of Operations
     Relation Expressions
     Logical Expressions
     Order of Procedure of Operation
     Built-in Factions
Basic Input/Output
     Input and Output Boxes
     Message Box
     Modality of Message Box
     Input Dialog Box
     Exercises
Control Statements
     Go to Statement
     Conditional Control Statement
     Selection Structure
     If …….. then structure
     If …..then…..else Structure
     Select Case Structure
     Loop Structure
     While ……..wend Structure
     Do …… while loop Structure
     Do …….Un till loop
     Do……..loop while
     Do……..loop until
     For……..next Loop
     Exit for and Exit Do Structure
   Exercises
Basic ActiveX Controls
     Command Button
     Label Control
     The Timer
     Text Box
     Check Boxes
     Option Buttons
     Frames
     List Box Control
     Combo Box Control
     Scroll Box Control
     File Controls
     Exercises
Arrays
     One Dimensional Arrays
     Declaring Arrays
     Assigning Value to An Array
     Two Dimensional Array
     Entering Data to Two Dimensional Array
     Control Arrays
     Exercises
Graphics
     Drawing With Visual Basic
     Scale Properties
     Types of Graphics
     Using Colors
     Graphics Controls
     Image Box Control
     Picture Box Control
     Shape Control
     Graphics Methods
     Line Method
     Circle Method
     Pest Method
     Cls Method
     Move Method
     Exercises
Advance ActiveX Controls
     Adding Advanced Controls to Toolbox
     The common Dialog Control
     Common Properties of Dialog Boxes
     Open Dialog Box
     Save As Dialog Box
     Color Dialog Box
     Font Dialog Box
     Print Dialog Box
     Rich text Box Control
     Msflexgrid Control
     Exercises
Procedure and Functions
     Subprograms
     Types of Subprograms
     Scope of Subprograms
     Writing Subprograms in From Modules
     Sub Procedures
     Functions
     Argument Passing Mechanism
     Creating a Separate Code Module
     Exercises
Database Programming
     Database
     Relational Databases
     Biblio.mbd
     Database Management System (DBMS
     Visual Data Manager
     Entering Data Into the database
     Data Management Tools
     Data Control
     Data Bond Controls
     Record set Object
     Data Access Object (DAO)
     Accessing DAO Objects
     Naming DAO Objects
     Refereeing To DAO Object
     Object Variables
     Workspace Collection
     Databases Collection
     Table Defs Collection
     Fields Collection
     Indexes Collection
     Seek Method
     Structured Query Language(SQL)
     Exercises
ActiveX Data Objects
     ActiveX Data Object(ADO)
     The ADO Data Control
     Data Bound Controls
     ADO Object
     ADO Collection
     Connection Object
     Command Object
     Record set Object
     Data Environment Designer
     Accessing Records By Creating Command Object
     Using Data Environment with the Data Grid Control
     Data Report Designer
     Data Report Object
     Exercises
Visual Basic and Web
     The Web sever Control
     Web browser Events
     The Internet Explorer Object
     Exercises
Scripting Objects
     Visual Basic Scripting Objects
     File System Objects (FSO) Objects
     Text Stream Object
     Reading Data From Text Files
     Managing Folders And Files
     Exercises
                              Introduction To Visual Basic

Computer Programming Language

    The computer languages can be categorized based upon the following
criteria:
          Low level and High level
          Procedural and Event oriented
          High visual and low visual
          Interpreted and Complied

Low-level & High-level
   A computer language can be described as a low-level or high-level
language. A language close to the machine language is called low-level
language and a language close to human-language is called high-level
language.
         Low-level lingual are to the machine language. The machine
language consists of 0s and 1s. The program written in machine language
work with great speed. Assembly language is an example of low-level
language. It is generally used for writing operating system and firmware.

          High-level languages are people-oriented. The instructions in
these languages are more like human languages. BASIC, FORTRAN,
COBOL, PASCAL, etc are examples of high-level languages. Unlike
low-level languages, these languages are easier to learn. These languages
are used for writing application programs. A high-level language, for
example may be used for writing a program for maintaining the budget of
a company.


Procedure-Oriented And Event-oriented
The program written in procedure –oriented language is executed with
out any action by the user. A computer program written in a procedure-
oriented language is executed, statement by statement until all the code is
executed. Procedural languages are high-level languages. Prior to 1990,
most high-level languages were procedural languages.

   Program written in event-oriented languages are different as their
execution depends upon the user. They wait for the user to take some
action and they perform a task in response to the action of the user.

   Event-oriented languages were developed with the advent of
Microsoft Windows for MS-DOS computer systems. These systems
provided Graphical User Interface or GUI (pronounced as goo-ey)

   In the GUI, an event may be the pressing of a key on the keyboard or
the click of a mouse button. In an event-oriented program, the computer
waits for an event and it takes the action accordingly.

Low-Visual and High-Visual Languages
   Computer languages can also be described as low-Visual and High-
Visual languages.

          In low-visual language it is often difficult to design computer
forms and reports. High-visual languages, on the other hand, support
GUI. Theses languages provide easy methods for designing, forms,
reports, data entry screens, etc. Visual Basic language is an example of
high-visual language.

Interpreted and Complied Languages
   A computer language can be interpreted or complied. In interpreted
languages, the programs executed statement by statement by interpreting
each statement of the program. In complied languages, the whole
program is first complied into machine code and then it is executed.

   Visual Basic is both interpreted and complied language. When the
visual Basic program is developed , it is executed in interpreted mode.
After completing the program, it is complied and the complied and the
complied program are used.
History of The Visual Basic

   Visual Basic evolved from BASIC (Beginner’s All-purpose Symbolic
Instruction Code). BASIC was developed in the 1960s by Professors
John Kemmeny and Thmoas Krrtz of Dartmooth College. It was
developed as a language for writing simple programs to help people learn
how to program.
          BASIC became a popular language and its widespread use led
to many enhancements in the language. With the development of
Graphical User Interface for personal computer (Microsoft Windows) in
the late 1980s and early 1990s, the version of BASIC suitable for GUI
environment was developed. It was named Visual Basic and it was
developed by Microsoft Corporation in 1991.

          Prior or Visual BASIC, writing Windows-based application
was very difficult and time-consuming, Visual BASIC greatly simplified
writing of window application programs, since 1991, eight versions of
Visual Basic have been released. The latest version is Visual Basic Net.

          Visual Basic is a Microsoft Windows programming language. It
provides and Integrated Development Environment (IDE) for creating
applications, the environment is which a programmer can create, run and
debug a program is called IDE. The processes of rapidly writing an
applications program is sometimes also called Rapid Application
Development (RAD). Visual Basic is the worlds, most widely used RAD.

          There are three different versions of Visual Basic. These are:
the learning Edition, Professional Edition and Enterprise Edition. Each
edition provides specific features and is suitable for a specific se of
environment.

         Visual Basic Learning Edition
           The learning Edition provides basic programming features. This
edition is generally used by students in educational institutions for
learning the language.

         Visual Basic Professional Edition
                 Professional Edition provides full features of the
language. It is used by professional programmers to develop Visual Basic
application programs for commercial purpose.

         Visual Basic Enterprise Edition
          Enterprise Edition provides features for creating a distributed
application program. This edition includes all the features of the
Professional Edition, plus tools such as SQL Server, IIS, SNA server, etc

         Visual Basic IDE
           Visual Basic is a both a tool and a language. The tool is the
Visual Basic Integrated Development Environment (IED). It provides
facilities for writing, debugging and running programs in one
environment. It is used to develop the Graphic User Interface ((GUI) of
the program, the language is used to write the code that executes behind
the GUI of the program.

         Steps in Developing VB Application
           An application in Visual Basic development environment is
developed in three steps. These steps are followed in every application
whether it is a simple or a complicated and extensive application. These
steps are:

             Drawing the user interface by placing controls on the
              form.
             Assigning properties to the controls.
             Writing and attaching the code to the control events and
              writing independent procedures.

         The Visual Basic application is developed in stages. In each
         stage, the code for one procedure is written and tested. This
         makes writing of the application programs simpler. It also
         minimizes program errors.
   Standard EXE Project

    When Visual Basic is loaded, the new project dialog window is
displayed. This dialog window contains various types of
applications that can be created in Visual Basic IDE. It contains the
following three tabs.

       The New tab contains options for creating new Visual
        Basic applications.
       The Existing tab is used for opening an existing
        application saved on the disk.
       The Recent tab is used for opening a project that has been
        recently used onto the Visual Basic IDE.

   The New Project dialog is displays each time the Visual Basic
   is loaded, their is check Box on the lower left corner of this
   dialog. If this check box is checked, this dialog is not displayed
   when the Visual Basic is started. It is, however, displayed when
   the New Project command in the File menu is executed.
The New Project dialog window contains a number of different
types of applications that can be created in Visual Basic. Their
number and type on this dialog window depends upon the
edition of the Visual Basic. For example, the learning edition of
visual basic contains fewer items that the Professional Edition,
the above figure shows the new project dialog of visual basic
Enterprise Edition.

      In New Project dialog, Standard Exe is highlighted by
default, it is used to create a standard executable program in
Visual Basic, and standard EXE application uses the most
common Visual Basic features.

Visual Components of Visual Basic IDE
     Figure below show the visual basic IDE for Standard
EXE project. The visual basic IDE consists of various
components and the following windows:

                   Form Window
                   Form Layout Window
                   Properties Window
                   Project Explorer Window
                   Toolbox
   Title Bar            Menu Bar             Tool Bar




   Tool Box                         Form

Form Window
          Form window contains a form. The graphical user
   interface (GUI) of the visual basic program is created and
   displayed on this window. The FUI of a program consists of
   several buttons, text boxes, etc/ the user provides input through
   various controls on the form and the output of the program is
   also displayed on the form.
Form Layout Window

      Form Layout a window is used to specify the position of the
program window on the computer screen when the program is
executed. It consists of an image representing the computer serene and
a form. The position of the active form relative to the computer screen
is shown.
    The position of the form on the screen can be adjusted by
    dragging the form with the mouse the desired position.




Properties Window
          The properties of an object in visual basic its attributes
    such as size, color, position, appearance, font, etc. Properties
    window displays these attributes of the selected object.

          Each control in visual basic has a unique set of
    properties. Some properties such as height, width, color etc, are
    common to all controls. While other properties are unique to
    each object. When an object or a control is selected. Its
    respective properties appear in the properties window.
Properties window contains two tabs: alphabetic and
Categorized. When alphabetic tab is selected, the properties are
listed in alphabetic order.
This is the default setting.

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:49
posted:4/13/2012
language:English
pages:16
Description: Programming with Visual Basic