Professional Documents
Culture Documents
Agenda: Application Design Application Design
Agenda: Application Design Application Design
Week 4
Application Design
Agenda
Application Design
5 Steps of Application Design
Pseudocode
TOE Chart
Programming Conventions
Comments
Indentation
Line Continuation
Naming Conventions
Tutorial 2
Programming Conventions
Developers follow certain conventions when they write
code
Conventions dictate naming and documentation styles
Helps other developers work with your code more easily
Will even help you!
Conventions continued…
Common conventions for Visual Basic:
Comments
Indentation
Line Continuation
Naming Conventions
Comments
Used to explain code (what it is doing)
In VB the apostrophe (‘) is used
Anything after an ‘ is not interpreted by the
computer
In your applications always include 3 things
at the top of the main forms code:
1. Name:
2. Date:
3. Program Description:
Comments
Comments appear green by default
'Send a message to the user
MsgBox "CPU255 - Introduction to Programming is fun!"
Indentation
Do This:
Private Sub Command1_Click()
Dim x As Integer
For x = 1 To 3
y=1+x
Next x
End Sub
Don’t do this:
Private Sub Command1_Click()
Dim x As Integer
For x = 1 To 3
y=1+x
Next x
End Sub
Line Continuation
VB allows you to break a long line of code over into the
next line
Use a space followed by an underscore ( _) at the point
you want the line to break
This can be very useful to help improve your code
readability
Example:
Naming Conventions
When adding a form or control VB assigns it a
default name
Example: the 1st Command Button added to a
form is named Command1, and the 2nd is
Command2
In this course, you must follow the naming
convention syntax for:
1. Controls
2. Forms
3. Variables (discussed next lecture)
Command1 cmdExit
Example:
a text box used to enter customers first name:
txtFirstname
txtFirstName
Methods
Methods are pre-defined procedures built into
objects
They define the behaviour (or tasks) of objects
Examples of Methods used in Tutorial 2:
object.SetFocus
[form.]PrintForm
Built-In Functions
Most programming languages come with a prewritten
set of functions
Functions are pre-defined procedures or routines
Similar to object methods, however functions return a
value
Two types of Functions:
1. Numeric Functions
2. String Functions
Functions
1. Numeric Functions:
Deal with ways of manipulating and converting numbers
2. String Functions:
Deal with ways of manipulating and converting strings
String Functions used in Tutorial 2:
1. Val()
2. Format()
TabIndex
Property of Objects (object.TabIndex)
Permits the user to access active controls on
forms by pressing the Tab key
Order of access is determined by predefined
order as set by the programmer
First object added to a form is assigned a
default TabIndex value of 0
Access Keys
Allows users to select objects using the “Alt” key in
combination with a number or letter (must be unique)
To set an access key place the ampersand (&) in the
caption property
Example:
&Save File E&xit
Concatenation Operators
Join multiple strings into a single string
The plus sign (+) and ampersand (&) can be
used to concatenate strings
Example:
Getting Help
F1 key for context-sensitive help
MSDN Library Visual Studio 6.0
World Wide Web
Hands-On Tutorial
Tutorial 2
Lesson B – Building the User Interface
Lesson C – Coding, Testing, Debugging, and
Documenting the Application