REV 01
DDC 3363
Programming III
Main Reference
Bradley, Julia Case and Millspaugh,
Anita C. (2009), Programming in Visual
Basic 2008, Mc Graw Hill
DDC 3363
Programming III
1
REV 01
Chapter 1: Introduction to Visual
Basic .NET 2008
Objectives
• Describe the process of visual program design and development.
• Explain the term object-oriented programming.
• Explain the concepts of classes, objects, properties, methods, and
events.
• List and describe the 3 steps for writing a Visual Basic project.
• Describe the various files that make up a Visual Basic project.
• Identify the elements in the Visual Studio environment.
• Define design time, run time, and debug time.
• Write, run, save, print, and modify your first Visual Basic project.
• Identify syntax errors, run-time errors, and logic errors.
• Use Auto Correct to correct syntax errors.
• Look up Visual Basic topics in Help.
DDC 3363
Programming III
2
REV 01
Chapter 1: Writing Windows
Applications with VB
• Windows Graphical User (GUI) Interface
– Defines how elements look and function
Text boxes
Check box
Radio
buttons
Message box
Buttons
Picture box
Label
DDC 3363
Programming III
3
REV 01
Chapter 1: Writing Windows
Applications with VB
Windows are called
forms.
Elements are called
controls and are added
using a toolbox.
DDC 3363
Programming III
4
REV 01
Chapter 1: Programming Languages Procedural, Event Driven, and Object
Oriented
• Procedural—Cobol, Fortran, Basic
• Program specifies exact sequence of all operations.
• Event-Driven Programming(VB 6.0 and previous)
• Contain some elements of object-oriented programming, but not
all
• Object-Oriented Programming (OOP) (VB .NET)
• User controls sequence
–Click event
–Double Click event
–Change event
DDC 3363
Programming III
5
REV 01
Chapter 1: The Object Model
In VB, you will work with objects that have properties,
methods, and events. Each object is based on a
class.
• Objects equate to Nouns.
– Forms are windows.
– Controls are components contained inside a form.
• Properties equate to Adjectives.
– Color or size of a Form
• Methods are like Verbs.
– Typical methods include Close, Show and Clear
DDC 3363
Programming III
6
REV 01
Chapter 1: Object Model
• Events occur when the user takes action.
– User clicks a button, User moves a form
• Classes are templates used to create a
new object.
– Classes contain the definition of all available
properties, methods, and events.
– Each new object created is based on a class.
• Creating 3 new buttons makes each button
a instance of the Button class.
DDC 3363
Programming III
7
REV 01
Chapter 1: Object Model Analogy
• Class = automobile
• Properties of automobile class= make,
model, color, engine, year
• Object = Each individual auto is an
object.
– Object is also an Instance of the automobile
class.
• Methods = start, stop, speedup,
slowdown
• Events of automobile class = Arrive,
Crash
DDC 3363
Programming III
8
REV 01
Chapter 1: Visual Studio .NET
• Included in Visual Studio .NET 2008
• Visual Basic (can also be purchased separately)
• Visual C++
• C# (C sharp)
• J# (J sharp)
• F# (F sharp)
• .NET 3.5 Framework
• Visual Studio .NET Editions
• Express
• Standard
• Professional
• Team System
DDC 3363
Programming III
9
REV 01
Chapter 1: Writing Visual Basic
Projects
The 3-step process when writing a Visual Basic
application:
•
•
1. Set up the user interface
2. Define the properties
3. Create the code
Planning
•
•
•
Design the User Interface.
Plan the Properties.
Plan the Basic Code; follow the language syntax rules; use
pseudocode (English expression or comment describing action)
then you move on to
Programming (and use the same 3-step process)
•
•
•
Define the User Interface.
Set the properties.
Write the Basic code.
DDC 3363
Programming III
10
REV 01
Chapter 1: VB Application Files
•
•
•
•
•
•
One Solution File - think of 1
solution file equals 1 project
HelloWorld.sln
Solution User Options File
HelloWorld.suo
Form Files
HelloForm.vb
Resource File for the Form
HelloForm.resx
Form Designer
HelloForm.Designer.vb
Project User Options File
HelloWorld.vbproj.user
Once a project is run, several more files are created by the system. The
only file that is opened directly is the solution file.
DDC 3363
Programming III
11
REV 01
Chapter 1: Visual Studio Environment
The Visual Studio environment is where you create and
test your projects. In Visual Studio, it is called an
•Integrated Development Environment (IDE) consisting
of various tools including:
•
•
•
•
•
•
Form Designer
Editor for entering and modifying code
Compiler
Debugger
Object Browser
Help Facility
DDC 3363
Programming III
12
REV 01
Chapter 1: Environment Settings
Studio 2008
provides a new
option that allows
the programmer to
select the default
profile for the IDE.
DDC 3363
Programming III
13
REV 01
Chapter 1: The IDE Initial Screen
The Visual Studio
IDE with the Start
Page open, as it
first appears in
Windows XP,
without an open
project
DDC 3363
Programming III
14
REV 01
Chapter 1: IDE Main Window
DDC 3363
Programming III
15
REV 01
Chapter 1: IDE Main Window
Help
Toolbox
Form
Designer
Document
window
Solution
Explorer
DDC 3363
Properties
window
Programming III
16
REV 01
Chapter 1: ToolBox
You can scroll to view more
controls.
To sort the tools in the toolbox:
•Right-click the toolbox and
select.
•Sort Items Alphabetically from
the context menu (shortcut
menu).
DDC 3363
Programming III
17
REV 01
Chapter 1: Modes
• Design Time
– used when designing the user interface and
writing code
• Run Time
– used when testing and running a project
• Break Time
– if/when receiving a run-time error or pause
error
DDC 3363
Programming III
18
REV 01
Chapter 1: Writing Your First Visual
Basic Project
Setting Up the Project
Hello World Project
1
2
3
DDC 3363
Programming III
19
REV 01
Chapter 1: Planning the Project
•
Design the user interface.
• Set up the form.
–Resize the form.
–Place a label and a button
control on the form using
the toolbox.
–Lock the Controls in place.
DDC 3363
Programming III
20
REV 01
Chapter 1: Planning the Project
•
After the user interface is designed, the next
step is to set the properties.
DDC 3363
Programming III
21
REV 01
Chapter 1: Setting Properties
•
Form
Name:
helloForm
Text:
Hello World by your name
•
•
•
DDC 3363
Programming III
Label 1
Name:
messageLabel
Text:
leave blank
Button 1
Name:
pushButton
Text:
Push Me
Button 2
Name:
exitButton
Text:
Exit
22
REV 01
Chapter 1: Setting Form Properties
•
•
•
The default startup
object is Form1
You may always
change the name of
the form
The properties
window shows
the files properties
DDC 3363
Programming III
23
REV 01
Chapter 1: Writing the Code
• While the project is running, the user can perform
•
•
•
•
•
actions.
Each action by the user causes an event to occur.
Write code for the events you want to respond to with
code.
Code is written as event procedures.
VB will ignore events if you do not write code.
VB will automatically name event procedures as the
object name.
DDC 3363
Programming III
24
REV 01
Chapter 1: More on Writing the Code
• When writing the code for your first
project, you will use the following:
• Remark Statement
• Assignment Statement
• Ending a Program
• Editor Window
DDC 3363
Programming III
25
REV 01
Chapter 1: Remark Statement
• Also known as Comment, used for
•
•
•
documentation; every procedure should
begin with a remark statement providing
explanation.
Non-executable
Automatically colored Green in Editor
Begins with an apostrophe ( ' )
• On a separate line from executable code
• At the right end of a line of executable code
'Display the Hello World message.
DDC 3363
Programming III
26
REV 01
Chapter 1: Assignment Statement
• Assigns a value to a variable
messageLabel.Text=" Hello World "
• Operates from right to left
• Enclose text strings in quotation marks (" ")
DDC 3363
Programming III
27
REV 01
Chapter 1: Ending a Program
• Methods always have parentheses. (This will
help you distinguish them from Properties which never
have parentheses.)
• To execute a method of an object you write:
Object.Method()
• Current Form may be referenced as Me
Me.Close( )
DDC 3363
Programming III
28
REV 01
Chapter 1: Editor Window
• Declarations Section
• Class list
• Method list
DDC 3363
Programming III
29
REV 01
Chapter 1: Run, Save, Modify, Print,
Test, Debug, and Execute
•
•
•
•
•
•
Run Project
• Open Debug Menu, Start Debugging.
• Start Debugging button on the toolbar.
• Press F5, the Start Debugging command.
Save Project - File Menu, Save All.
Modify Project if needed.
Print the Code.
Correct any Errors and Rerun.
When you start executing your program, the first step is
called compiling. Your goal is to have no errors during the
compile process: a clean compile.
DDC 3363
Programming III
30
REV 01
Chapter 1: Finding and Fixing Errors
• Syntax Errors
• Breaks VB’s rules for punctuation, format, or
spelling
• The editor identifies a syntax error with a squiggly
blue line and you can point to an error to pop up the
error message.
• You can display the Error List window and line
numbers in the source code to help locate the error
lines.
• Run-Time Errors
• Statements that fail to execute, such as impossible
arithmetic operations
• Logic Errors
• Project runs, but produces incorrect results.
DDC 3363
Programming III
31
REV 01
Chapter 1: Naming Rules & Convention
• Have a set of standards and always
•
•
follow them.
No spaces, punctuation marks, or
reserved words
Use camel casing.
• Examples
–messageLabel
–exitButton
–dataEntryForm
–paymentAmountTextBox
DDC 3363
Programming III
32
REV 01
Chapter 1: Recommended Naming
Conventions for VB Objects
Object Class
Example
Form
dataEntryForm
Button
exitButton
Label
totalLabel
TextBox
paymentAmountTextbox
Radio button
boldRadiobutton
CheckBox
printSummaryCheckBox
Horizontal Scroll Bar
rateHorizontalScrollBar
Vertical Scroll Bar
temperatureVerticalScrollBar
PictureBox
landscapePictureBox
ComboBox
bookListComboBox
ListBox
ingredientsListBox
SoundPlayer
introPageSoundPlayer
DDC 3363
Programming III
33
© Copyright 2026 Paperzz