Scripting and Programming in GIS PART A VISUAL BASIC - PowerPoint PPT Presentation

1 / 25
About This Presentation
Title:

Scripting and Programming in GIS PART A VISUAL BASIC

Description:

(3) Display the distance in km. Design. The Microsoft Visual Basic Environment . There are three steps to creating a Visual Basic program (1) Create the interface ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 26
Provided by: theunivers48
Category:

less

Transcript and Presenter's Notes

Title: Scripting and Programming in GIS PART A VISUAL BASIC


1
Scripting and Programming in GISPART A - VISUAL
BASIC
  • Dr Allison Kealy
  • Room B306
  • akealy_at_unimelb.edu.au

2
A 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.
3
Failure is part of the process. Programming is an
iterative process, where each iteration provides
helpful data about what did not work.
4
Lecture 1
  • Program Development Cycle
  • Introduction to Visual Basic
  • Variable Types
  • Object Entities

5
Software 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

6
Problem
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
7
Analysis
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
8
Example
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
9
Design
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.
10
Algorithm 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.
11
Implementation
Implementing the algorithm involves writing it as
a program. You must convert each algorithm step
into one or more statements in a programming
language.
12
Testing
Testing and verifying the program requires
testing the completed program to verify that it
works as desired. Dont rely on just one case
13
Maintenance
Maintaining and updating the program involves
modifying a program to remove previously
undetected errors. Organise all material that
describes the program
14
Class Assignment
  • Prepare the software development plan for the
    assignment

15
Applying 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.
16
Analysis
Problem Inputs
distances (in miles)
Problem Outputs
distances (in km)
Formula
1 mile 1.609km
17
Design
(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
18
The Microsoft Visual Basic Environment .
19
menu
toolbar
Project Explorer Window
toolbox
Properties
Form
Form layout
Project container window
20
Visual Basic Objects
  • Objects
  • Forms
  • Controls
  • Text boxes
  • Labels
  • Command Buttons

21
Naming 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

23
Visual Basic Events
24
Debugging
  • Step into
  • Step over
  • Run to cursor
  • Breakpoint
  • Watch value

25
Class 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.
Write a Comment
User Comments (0)
About PowerShow.com