Title: Principles and Concepts I
1Principles and Concepts I
- G- Code Learning Group (3)
- Jonathan Remo
- Mayank Srivastava
- Zhigang Wang
2Overview
- History of Computer Programming Languages.
- Visual Basic Concepts
- Application of Visual Basic
-
3- What is a Program?
- Program is a specific set of ordered operations
for a computer to perform.
- What is a Complier ?
- A special program that processes statements
written in a particular programming - language and turns them into machine language
or "code" that a computer's - processor uses.
4Charles Babbages Difference Engine
- The earliest form of a computer language was
physical motion. - The tasks were executed by changing the gears
which performed the calculations.
5Electronic Numerical Integrator (ENIAC)
- Calculations were performed using electrical
signals in stead of physical motion. - "Programmed" by presetting switches and rewiring
the entire system for each new "program" or
calculation.
6John Von Neumann
- Shared-program technique
- Conditional control transfer
- Conditional control transfer the brought about
the idea computer code should be able to branch
based on logical statements such as IF
(expression) THEN, and looped such as with a FOR
statement. - Conditional control transfer also gave rise to
the idea of libraries.
7Short Code
- Short Code was the first computer language for
electronic devices. - Required the programmer to change its statements
into 0's and 1's by hand.
8Grace Hooper and the Complier
- A compiler is a program that turns the language's
statements into 0's and 1's for the computer to
understand. - Lead to faster programming
9Auto Code
- The AutoCode-compiler, which compiles symbolic
assembler language on a Manchester Mark I
computer.
10Fortran
- The first of the major languages.
- Developed by IBM for scientific computing.
- Language included IF, DO, and GOTO statements.
- The basic types of data in use today got their
start in FORTRAN, these included logical
variables (TRUE or FALSE), and integer, real, and
double-precision numbers.
11LISP
- Designed for Artificial Intelligence (AI)
research. - The difference between this language and other
languages is that the basic and only type of data
is the list, denoted by a sequence of items
enclosed by parentheses. - LISP programs themselves are written as a set of
lists, so that LISP has the unique ability to
modify itself, and hence grow on its own.
12AlgolAlgorithmic Language
- Independent of specific type of hardware.
- Language was carefully and formally designed.
- Algols major contribution is being the basis for
Pascal, C, C, and Java. - It was also the first language with a formal
grammar, known as Backus-Naar Form or BNF.
13COmmon Business Oriented Language (COBOL)
- Designed from the ground up as the language for
businessmen. - Data types were numbers and strings of text.
- It allowed for the data to be grouped into arrays
and records, so that data could be tracked and
organized better.
14BASIC (Beginners' All-purpose Symbolic
Instruction Code)
- John Kemeny and Thomas Kurtz invents BASIC and
its compiler. It was developed at Dartmouth
College as a teaching tool
15Pascal
- Pascal was developed mainly out of necessity for
a good teaching tool. - Designed in a very orderly approach, it combined
many of the best features of the languages in use
at the time, COBOL, FORTRAN, and ALGOL. - The combination of features, input/output and
solid mathematical features, made it a highly
successful language. - Pascal also improved the "pointer" data type, a
very powerful feature of any language that
implements it. - It also added a CASE statement that allowed
instructions.
16C
- C was developed the Unix system. Unix gives C
such advanced features as dynamic variables (e.g.
variant), multitasking, interrupt handling,
forking, and strong, low-level, input-output. - Because of this, C is very commonly used to
program operating systems such as Unix, Windows,
the MacOS, and Linux.
17OOP and C
- In the late 1970's and early 1980's, Object
Oriented Programming, or OOP was developed. - Objects are pieces of data that can be packaged
and manipulated by the programmer. - In 1983 developed into the language C
- C was designed to organize the raw power of C
using OOP, maintain the speed of C and be able to
run on many different types of computers.
18Visual Basic (VB)
- Evolved from BASIC
- With the development of Microsoft windows
graphical user interface (GUI) in the late 1980s
and the early 1990s, BASIC evolved into VB. - VB is developed on using forms and windows using
in which a programs drags and drops into the
program.
19JAVA
- Netscape licensed Java for use in their internet
browser. - Has optimization problems
- Java may wind up as the instructional language of
tomorrow as it is truly object-oriented and
implements advanced techniques such as true
portability of code and garbage collection.
20Visual Basic Concepts
- VB is windows based programming language that
allows a programmer to build applications running
under Windows. - VB constructs the necessary building blocks that
a Windows application needs - Hence, very little coding needs to be performed
- Integrated development environment (IDE) allows
the programmer to create, run and debug Windows
programs in one application - VB is a EVENT driven language
- Code is written to respond to specific events
- Allows code to be short and is compartmentalized
by events.
21Visual Basic Environment
- How to start Visual Basic?
22Visual Basic Environment
- Integrated Environment Screen
- Menu Bar lists of commands
- Tool Bar quick access to mostly common used
objects - Formwindow where the application is designed
- Project Explorer a list of forms,modules,
classes or ActiveX components - Properties Window a list of the property
settings for a control - Tool Box a set of tools designing applications
- Form Layout set the forms screen position
23Menu Bar Tool Bar Project Explorer Prope
rties Window Layout Form
Toolbox Form
24Picture Box Text Box Command Button Option
Button List Box Vertical Scroll Bar Drive
Box File list Lines Data Control
Selection Tool
Label
Frame
Check Box
Combo Box Horizontal Scroll Bar Timer Directory
List Shapes Image Box OLE Control
25Operations on a Project
- How to Open?
- Choose the file open icon on the toolbar or the
file open menu - Type in or choose the name of the file to open
- Same as other MS software
26Operations on a Project
- How to Save?
- A VB project consists of many forms, modules, and
graphics, and all of them are saved within
separate files within the project - Project File Extensions
- Design-time Files
- Miscellaneous Development Files
- Run-time Files
- Saving a project
- Saving a form or module
- Automatic saving of project files and forms
- Using help
27Using Controls on a Form
- Adding a control to a form
- Selecting a control
- Resizing a control
- Deleting a control
- Moving a control
- Setting control properties
- Object Box displays the name of the selected
control - Properties List displays a scrollable list of
all properties for the selected control - Adding code to controls
- Option Explicit error preventing statement
28Adding Comments to Code
- Comments are useful to remind the programmer
about the purpose of the code or any problems
with it - Text within the code window are color coded
- Green comments
- Blue valid VB commands
- Black programmers code
29Building A Visual Basic Application
- Step 1 Draw the interface
- Step 2 Set properties
- Step 3 Write codes
- Step 4 Execute the program
30(No Transcript)
31Controlling the Program Flow
- Conditional Operator
- Operator Meaning
- Equal to
- gt More than
- lt Less Than
- gt More than and
equal - lt Less than and
equal - ltgt Not Equal to
32Controlling the Program Flow
- Logical Operators
- Operator Meaning
- And Both sides must be true
- Or One side or other must be
true - Xor One side or other must be
true but not both - Not Negates truth
33Controlling the Program Flow
- If Then - Else statement
- If conditions Then VB expressions
- Else
- VB expressions
- End If
- Case Select Statement
- Select Case expression
- Case value1 Block of one or more
VB statements Case value2 Block of
one or more VB Statements
34Declaring a Variable
- Dim Variable as Variable Type
- Dim r as Integer
- Dim pi as Double
- If variable is not declared the program will
consider it as an variant
35VB Codes
- Program for finding the volume of a cone and
a cylinder - Dim r as double
- Dim h as double
- Dim pi as double
- Dim v as double
- r Val(radius.Text)
- h Val(hght.Text)
- Pi 22 / 7
- v Pi (r 2) h
- volume.Text Str(v)
36Functions
- The general format of a function is
- FunctionName(arguments)
- where arguments are values that are passed on
to the functions
37Visual Basic Applications
38Problem Statement
- Calculate the commission
- Sales Volume() Commissions
- lt500 3
- lt1000 6
- lt2000 9
- lt5000 12
- gt5000 15
39Macro in Excel
- Function Comm(Sales_V As Variant) as Variant If
Sales_V lt500 Then CommSales_V0.03 Elseif
Sales_Vgt500 and Sales_Vlt1000 Then
CommSales_V0.06 Elseif Sales_Vgt1000 and
Sales_Vlt2000 Then CommSales_V0.09 Elseif
Sales_Vgt200 and Sales_Vlt5000 Then
CommSales_V0.12 Elseif Sales_Vgt5000 Then
CommSales_V0.15 End If End Function