Title: Scripting and Programming in GIS PART A VISUAL BASIC
1Scripting and Programming in GISPART A - VISUAL
BASIC
- Dr Allison Kealy
- Room B306
- akealy_at_unimelb.edu.au
2A disciplined approach is essential if you want
to create programs that are easy to read,
understand and maintain. You must follow
accepted style guidelines and avoid tricks and
programming shortcuts.
3Failure is part of the process. Programming is an
iterative process, where each iteration provides
helpful data about what did not work.
4Lecture 1
- Program Development Cycle
- Introduction to Visual Basic
- Variable Types
- Object Entities
5Software Development Method
- Specify the problem requirements
- Analyse the problem
- Design the algorithm to solve the problem
- Choose the interface
- Implement the algorithm
- Test and verify the completed program
- Maintain and documentation
6Problem
Specifying the problem requirements forces you to
state the problem clearly and unambiguously and
to gain a clear understanding of what is required
for its solution Your objective is to eliminate
unimportant aspects and zero in on the root
problem
7Analysis
Analysing the problem involves identifying the
problem inputs, outputs and any additional
requirements or constraints on the
solution. Develop a list of problem variables
and their relationships
8Example
Compute and display the total cost of apples
given the number of kgs of apples purchased and
the cost per kg of apples.
Problem Inputs
quantity of apples purchased (in kgs) cost per kg
of apples (in dollars per kg)
Problem Outputs
total cost of apples (in dollars)
Formula
total cost of apples cost per kg x kgs of apples
9Design
Designing the algorithm to solve the problem
requires you to develop a list of steps called an
algorithm to solve the problem and then verify
that the algorithm solves the problem as
intended. Discipline yourself to use top-down
design. List the major steps or sub problems,
then solve the original problem by solving each
of the sub problems.
10Algorithm for a Programming Problem
- (1) Get the data
- (2) Perform the computations
- (3) Display the results
Once you know the sub problems, you can attack
each one individually. This process is called
algorithm refinement.
11Implementation
Implementing the algorithm involves writing it as
a program. You must convert each algorithm step
into one or more statements in a programming
language.
12Testing
Testing and verifying the program requires
testing the completed program to verify that it
works as desired. Dont rely on just one case
13Maintenance
Maintaining and updating the program involves
modifying a program to remove previously
undetected errors. Organise all material that
describes the program
14Class Assignment
- Prepare the software development plan for the
assignment
15Applying the software development method
Problem
Your summer surveying job requires you to study
some maps that give distances in km and some that
use miles. You and your co-workers prefer to
deal in metric measurements. Write a program
that performs the necessary conversion.
16Analysis
Problem Inputs
distances (in miles)
Problem Outputs
distances (in km)
Formula
1 mile 1.609km
17Design
(1) Get the distance in miles (2) Convert the
distance to km (3) Display the distance in km
algorithm with refinements
(1) Get the distance in miles (2) Convert the
distance to km 2.1. The distance in km is 1.609
times the distance in miles (3) Display the
distance in km
18The Microsoft Visual Basic Environment .
19menu
toolbar
Project Explorer Window
toolbox
Properties
Form
Form layout
Project container window
20Visual Basic Objects
- Objects
- Forms
- Controls
- Text boxes
- Labels
- Command Buttons
21Naming Conventions
- frmConversion
- lblMiles
- cmdConvert
22- There are three steps to creating a Visual Basic
program - (1) Create the interface
- (2) Set the relevant properties
- (3) Write the code that executes when events occur
23Visual Basic Events
24Debugging
- Step into
- Step over
- Run to cursor
- Breakpoint
- Watch value
25Class Assignment
- Complete the code for the example shown in the
class to convert miles to kilometres. - Modify this interface to create one suitable for
the assignment.