CIS 112 :: Visual Basic Programming
Projects
+ Topics
Project #1 :: Panorama of
History
1. Basic VB IDE
Three basic modes
Design
Run
Break
Basic windows
Important IDE settings
Option Explicit
2. Project components
Forms (.frm)
Main project file (.vbp)
Executable (.exe)
Project folder
3. Naming conventions
VB object prefixes (frm, lbl, txt, cmd, etc.)
VB file prefixes (frm, exe, prj)
self-documenting code via choice of object names
4. Role of VB objects
Basic VB
objects
form
as primary
user interface
as
container of other objects
command button
as
initiator of action
as
presenting choices to user
label
to display
information for the user
to send
messages during program execution
resetting
to empty
text box
to receive
textual input from user
resetting
to empty
Basic object triad :: object . . .
has properties
responds to events
is acted on by methods
Basic object properties
height, width, left, top
forecolor, backcolor, font
visible, enabled
Etc.
5. Event-driven programming
Event wait loop
Basic VB events
Click
Double click
Load
Activate
Basic VB methods
Show
Hide
Move
SetFocus
6. Multi-form Projects
Adding forms to a project
Navigating among forms
Resetting form to original condition
7. Online Help
F1 function key
Help Index
Context Sensitive Help
8. Project Design Principles
Clean
Intuitive interface
Non-obtrusive
Cooper: The Inmates Are Running the Asylum
Nielsen: Usability
Heuristics
Tognazzini: Principles of
Interaction Design
9. Project Submission
Making an executable
Zipping & unzipping
Program testing
Project #2 :: Say What!
1. Design strategy
What do you want program to do?
How to achieve this goal?
Breaking into components
Identifying natural subroutines
Choosing subroutine type
Designing each component
Initialization
2. Variables basic storage
Basic idea of data types
Declaration
Initial value
Scope
Local
Module level (global)
Access
Assignment of values
Holder of information
Retrieval of values
3. Control arrays
same name (generalization)
shared code (generalization)
differentiated by index (individuation)
information supplied by IDE (Index As Integer)
4. Flow of control
subroutines
if-then-else
loops
5. Subroutines
Basic types
Event procedure
General procedure
Function
Pre-defined vs. user defined
Purpose
perspicuity (reveal program
logic)
code reuse
Triggering invocation, call
flow of program control
6. If-Then-Else (simple)
basic flow chart
7. For-Next (simple)
loop counter (loop control variable)
operation of loop
when is the loop entered?
what happens inside the loop?
when is the loop exited?
8. Interface control
Clickable
labels
Making
visible/invisible
Disabling buttons/labels
Enabling buttons/labels
9. Extras
Choose which
first: person or quote
Creative
representation
Sounds
Project #3 :: My Word!
1. Design strategy
What do you want program to do?
How to achieve this goal?
Identifying role of storage
Long term storage
Advantages
Disadvantages
Short term storage
Advantages
Disadvantages
Breaking into components
Identifying natural subroutines
Choosing subroutine type
Identifying data flow among
program components
To
From
Initialization
Designing each component
Breaking down complex process
Identifying subtle pitfalls (e.g., double letters)
Leveraging available tools (e.g., replacing counted letter)
2. Operators (intro)
Arithmetic
+
* /
String operators
&
3. String data type
Declaration
Varieties
Variable length
Fixed length
VB string functions (intro)
Mid
Instr
Replace
Str
Ucase
4. Files permanent storage
Why use files?
When to use files
How to use files
File referencing conventions
Path names
App.Path
Opening
Closing
Reading data from file
Input # statement
5. Composing a complex response
Recognize
textual output is simply a string
Advantage
gained by concatenation
Dealing with
numeric values (Str)
6. Advanced TextBox usage
Clearing text box
Set Focus
Place limits on length of word typed
7. Boolean data type
Boolean variables
Boolean Functions
Use to simplify code
Use within If-Then or
While-Wend
8. Advanced program control
General procedures
Call
Data Flow
Execution Flow
Parameters
Declaration, data types
Passing values to subroutine
Pass by Value (ByVal)
Pass by Reference (ByRef)
Default
Receiving values from procedure
Functions
Call
Function data type
Data Flow, Execution Flow,
Parameters
Returning values
Function value
ByRef parameter
9. Random number generation
Rnd
Randomize
Writing a useful function
10. Extras
Count number of
moves
Limit number of
moves
Color codes to
show which letters are correct, etc.
Keep running
score
Record best
scores
Project #4 :: 8 Puzzle
1. Design strategy
What do you want program to do?
How to achieve this goal?
Discover interplay between storage and display
Displaying puzzle as it is being
solved
Storing state of puzzle
Storing solution to puzzle
Representation issues
Solution state
Empty tile
Updating after a move without
losing information
Initialization
Storage
Display
Calculating grid and cell size
Useful values (e.g., color array)
Breaking into components
Identifying natural subroutines
Choosing subroutine type
Identifying data flow among
program components
Designing each component
Identifying subtle pitfalls
Not all moves are allowed
How to recognize a bad move
Not all puzzles can be solved
How to process a proposed move
Leveraging representation to process a move
Checking :: is move OK?
Updating
The display
The stored state of the puzzle
Checking to see if puzzle was solved
Breaking down complex processes
2. Two dimensional arrays
rows, columns
indices
processing entire array
Accessing individual elements
3. Nested for loops
Use for two-dimensional arrays
4. The VB Flex Grid
Adding to ToolBox
Properties
Rows, Cols
FixedRows, FixedCols
Height, Width, Left, Top
Font
ScrollBars
GridLines
Rows &
columns
indexing
accessing
effect of clicking on
indexing
properties
RowHeight, ColWidth
Cells
properties
CellForeColor, CellBackColor
Text
5. VB color constants
Names
Accessing a set of colors at will
one dimensional array of colors
data type of color constant
changing color of a FlexGrid cell
6. Extras
Count number of
moves
Keep running
score
Record best
scores
Allow player to
back up to previous position
Record best
moves
Project #5 :: Cellular
Automata
1. Design strategy
What do you want program to do?
How to achieve this goal?
Discover interplay between storage and display
Displaying CA as it runs
Array of colors
Matching colors to states
Storing state of CA
Representation issues
States (2-d array)
Colors (1-d array)
Transition function (code)
Breaking into components
Identifying natural subroutines
Choosing subroutine type
Identifying data flow among
program components
Identifying subtle pitfalls
Cells cannot be updated until
all new states have been calculated
Designing each component
Initialization
Storage
Display
Useful values (e.g., color array)
Running the machine
How to calculate a new state for
one cell
How to store new cell info until
all cells are ready
Updating CA
Storage
Display
Breaking down complex processes
Overcoming programming language roadblocks
Normal updating process is too slow in VB 6.0
2. Two dimensional arrays
(review)
3. Nested for loops (review)
4. The VB Flex Grid (review)
5. Extras
Add Conway
& Fredkin transitions
Allow dynamic
resizing of grid using ListBox
Allow user to
choose initial configuration by clicking on cells
Allow user to
step through CA run
Allow user to
store interesting configurations