Escolar Documentos
Profissional Documentos
Cultura Documentos
Introduction to
Visual Basic 2010
McGraw-Hill
Chapter Objectives (1 of 2)
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 three steps for writing a Visual
Basic project.
Describe the various files that make up a Visual Basic
project.
1-2
Chapter Objectives (2 of 2)
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.
1-3
Check box
Radio buttons
Message box
Buttons
Picture box
Label
Programming LanguagesProcedural,
Event Driven, and Object Oriented
Object Model (2 of 2)
Events occur when the user takes action.
User clicks a button, User moves a form
1-8
1-9
1-10
1-11
VB Application Files
One Solution Filethink of one solution file equals one project: HelloWorld.sln
Solution User Options File:
HelloWorld.suo
Form Files:
HelloForm.vb
HelloForm.resx
Form Designer:
HelloForm.Designer.vb
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.
1-12
Form Designer
Editor for entering and modifying code
Compiler
Debugger
Object Browser
Help Facility
1-13
1-15
Toolbars
Document Window
Form Designer
Solution Explorer Window
Properties Window
Toolbox
Help
Document window
Solution Explorer
Properties window
1-16
Tool Box
You can scroll to view more
controls.
To sort the tools in the
toolbox:
select.
Sort Items Alphabetically from
the context menu (shortcut
menu).
1-17
Modes
"LookattheTitleBar"
1-18
3
1-19
1-20
Setting Properties
Label 1
Name
MessageLabel
Text leave blank
Button 1
Name
PushButton
Text Push Me
Button 2
Name
Text Exit
Form
Name
HelloForm
Text Hello World by
your name
ExitButton
1-23
When writing the code for your first project, you will
use the following:
Remark Statement
Assignment Statement
Ending a Program
Editor Window
1-24
Remark Statement
Assignment Statement
1-26
Ending a Program
Methods always have parentheses. (This will help you
distinguish them from Properties which never have parentheses.)
Me.Close()
1-27
Editor Window
Declarations Section
Class list
Method list
1-28
Run Project
1-29
1-30
Syntax Errors
Breaks VBs rules for punctuation, format, or spelling
Smart editor finds most syntax errors, compiler finds the rest.
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.
1-31
Examples
MessageLabel
ExitButton
DataEntryForm
PaymentAmountTextBox
1-32
Example
Form
DataEntryForm
Button
ExitButton
Label
TotalLabel
TextBox
PaymentAmountTextbox
Radio button
BoldRadiobutton
CheckBox
PrintSummaryCheckBox
RateHorizontalScrollBar
TemperatureVerticalScrollBar
PictureBox
LandscapePictureBox
ComboBox
BookListComboBox
ListBox
IngredientsListBox
SoundPlayer
IntroPageSoundPlayer
1-34