Introduction to Computer
Programming
Instructor Contact Information:
John A. Rose, PhD (Assoc. Prof., APU ICT Institute)
APU Office: Building B, Room 414
Phone: x4414
E-mail:
[email protected] Website: http://www.apu.ac.jp/~jarose/
Texts and Materials
Primary Text: ‘Beginning VB.NET 2003’
Authors: T. Willis, J. Crossland, R. Blair
Publisher: Wiley (2004)
ISBN (Int’l Standard Book Number): 0-7645-5658-4
Resource: ‘Introduction to Visual Basic .NET
Programming’
H. Gunarto (Publisher, Tech Publications)
ISBN: 981-214-154-5
‘Introduction to Computer Programming’
Slide set on Basic Programming with VB Studio .NET
Available in ‘Instructional Materials’ (J. Rose, Spring Q1 2007)
PowerPoint slides
A Slide-based Course Pack also available
with Prof. N. Dahlan (N.B.: our approach may differ somewhat)
Course Syllabus (tentative)
Introduction to VB .NET
Lecture 1 – Introduction and Operation of VB .NET
Lectures 2-3 – Creating Simple Programs with VB .NET
Data and Control Structures
Lectures 4, 5 – Variables and Data Types
Lecture 6 – Decision Structures
Lecture 7 – Loop Structures
Midterm Examination
Lecture 8 – Subroutines and Functions (Methods)
Lecture 9 – File Input and Output
Lecture 10 – Arrays
Enumerations and Structures
Lectures 11-12 – Enumerations
Lecture 12 - Structures
Lectures 13– Working with Structures (Array Lists)
Final Examination or Submission of Final Project
Course Methodology
Lecture materials will be distributed at the beginning of each
class…
Followed by the Lecture.
Where possible, examples will be presented with figures.
Each class is 95 minutes. After each lecture-period:
students will then be provided time for practice (as time permits).
For a total of 95 minutes (lecture + practice)
Teaching Assistants (TAs) will be available to answer questions
during the practice period.
Note: substantial practice and work beyond the class period will
be required.
Course Evaluation (Grading)
The final grade (100%) will be awarded using the following
criteria for evaluation (tentative):
Attendance: 20%
Students should come to each class.
Note: points will be deducted for lateness and breaking lab rules.
Mid-term Exam: 35%
An in-class test after Lecture 7 (Loop Structures)
Final Examination: 45%
A comprehensive, in class test over all course material.
Important Notes about grading:
Homework (VB .NET Projects):
Will be assigned occasionally (do the assigned tasks!)
It is your responsibility to come to all classes, and do all tasks.
Note carefully that the above is tentative.
The above weights/items are subject to change.
Miscellaneous Instructions
Students should bring their own
data storage devices:
Necessary for storing work:
USB 2.0 Flash Memory (preferred)
64 MB or higher
Windows XP Compatible
CD-RW
650 or 700 MB
Floppy Disk
3.5’, 1.4 MB
These can be purchased in the APU
Book Store.
Lecture 1: Introduction to VB.NET
Outline
Introduction:
Computers, Information, and Information Processing
Software vs. Hardware
Programming Languages
Interpreted vs. Compiled Languages
Visual Basic (VB)
VB.NET
Our IDE for Windows Applications: Visual Studio.NET
Introduction
Basic Operation
Introduction to Basic Program Design
Basic process for program preparation
Simple Example: ‘Hello World’
Program design
Form and Controls arrangement
Adding code
Running, Testing, and Saving the Program
What is a Computer?
A computer is a logical device for processing information.
Specifically, computers process data.
Data = structured information
Base: Silicon VLSI technology
VLSI = Very Large Scale Integrated circuits
Computers are Powerful!
Can perform logical computations much faster than Humans.
Current speed (desktop!): 4 x109 basic operations/sec (GHz)
Each a simple logical operation (division, shift, write, etc)
Computers are Limited…
Computation basically sequential…
One operation at a time.
In contrast, Humans use parallel processing ( by neurons).
We are better at complex tasks (e.g., Vision, Pattern Recognition)
Computers not very ‘adaptive’…
Standard computers mainly do what they are told.
Communication difficult (computers think logically):
Programming languages (and programmers) required!
Software vs. Hardware
At the most basic level computers can be decomposed into two
components:
Hardware and Software
Hardware = the physical components of the computer system.
Data Processing: The Central Processing Unit (CPU)
Data Storage: Memory storage devices:
RAM (primary), Hard drive (secondary), flash disks (peripheral), etc
Data Communication: Devices for Input/Output:
Input: Keyboard, mouse, etc
Output: Display, printer, speaker
Software = the computer programs that run on a computer
These establish logical control over the hardware:
Manage the details of Data Processing, Storage, and Communication.
The Operating System (OS): primary system control
Windows, Unix, Linux, etc
Application Software: MS-Word, PowerPoint, Excel, etc
User-built Applications: using a Programming Language
Computer Languages
Computer languages can be classified in three types:
Machine Languages:
Languages that the Computer can understand…
Each operation a string of digits (1’s and 0’s)
Machine Dependent: only usable on one platform.
Difficult for humans to freely use.
Assembly Languages:
‘English-like’: Uses words from natural languages…
Each an abbreviation for a single machine language operation.
Translated to Machine Language by special programs:
Assemblers
Still not convenient for Humans.
High-Level Languages:
So-called Programming Languages.
Single statements can accomplish bigger tasks:
Groups of a set of related basic operations.
Much more convenient for Humans.
Programming Languages
Many Programming Languages have been developed.
Some major High Level Languages are:
Languages allow communication between humans and computers…
This involves converting abstract algorithms for solving problems into a form
understandable by the computer.
An ‘executable’ (i.e., run-able) form.
Such a converted algorithm is called a program.
The folks that do the conversion (at the high level) are us…the
programmers.
Interpreted vs. Compiled Languages
Before execution, instructions in a program must be converted:
from a text file (words in a Human language)…
to an executable form (first to assembly, then to machine language)
Two flavors exist for this conversion process:
In advance (compiled all at once).
Conversion by a program called a ‘compiler’.
Faster, but less adaptable.
‘On the fly’ (interpreted one instruction at a time):
Conversion by a program called an ‘interpreter’.
Slower, but can be modified at ‘run-time’.
Programming languages may be of either type...
Interpreted: Old MS-DOS ‘batch programs’
Compiled: C, C++, and BASIC
Some (JAVA, VB .NET) are essentially a combination of both:
VB .NET: code first compiled into ‘MicroSoft Intermediate Language’…
Portions of MSIL code later interpreted by an ‘MSIL converter’ to executable
code.
So-called, ‘Just-In-Time (JIT) Compilation’.
Either way, some kind of text editor is required to write the program.
Visual Basic and VB .NET
BASIC
Beginner’s All-purpose Symbolic Instruction Code
Developed as an extension of C, to be a general-purpose
programming language.
Visual BASIC (VB)
BASIC + a Graphical User Interface (GUI)
Greatly eases the creation of Windows applications
Especially, by facilitating the use of re-usable components
Visual BASIC .NET
A programming language based on VB 6.0
Working on the .NET framework of the Microsoft Corporation
A Platform for cross-language development (C#, VB. NET, J#)
Includes a large standard library
Visual Studio .NET
Microsoft’s Integrated Development Environment (IDE) for VB
.NET.
Intended mainly for Windows Applications and Web Applications.
We will use Visual Studio .NET to create all of our programs.
Starting VisualStudio.NET
Creating a New Project
The VB.NET start screen should appear:
Creating a New Project (cont)
The ‘New Project’ dialog box will appear.
Visual Studio.NET Screen
The main screen will appear:
Visual Studio.NET Screen (cont)
Double-clicking the Design Window brings up the Code Editor.
This shows your project’s current VB code.
Flow Chart for Program Preparation
Let’s Make a Simple Program
We start by making a Program Plan:
A simple description of the desired characteristics and
functionality.
Often includes an efficient method of solution (algorithm)
Example: a plan for adding two decimal numbers.
Simple ‘Welcome’ program (plan):
Program purpose: Display two simple messages; exit.
We will use three buttons (each called a ‘Control’)
We will use VB.Studio’s Design Window to create these.
Desired functionality (program behavior):
Clicking Button 1 (‘Welcome’ Button):
Display ‘Welcome to VB .NET’
Clicking Button 2 (‘Hello’ Button):
Display, ‘Hello, World!’
Clicking Button 3 (‘Exit’ Button):
Exit (close the program)
We will add each to our Form using the Design Window…
…and then add some simple VB .NET code.
Step 1: Making the Project
Step 2: Form and Controls Arrangement
We now add 1 Label and 3 Buttons to our form…
Step 3: Setting Control Properties
Step 4: Adding the Program Code
Write the VB code for each button, separately.
Step 4: Adding Code (cont)
Step 5: Program Testing
Step 6: Saving the Program
Conclusion
In this lecture, we have discussed:
Computers and Data Processing
Programming Languages,
Visual Basic (VB .NET)
And become acquainted with the basics of using VB Studio .NET:
Our IDE for building VB Windows Applications.
By making our first simple application.
With the remainder of the lecture, you should practice:
Open VB .NET and get familiar with the GUI;
Try, yourself, to make the simple program we discussed.
Test, save, and verify creation of the project files.