Table of
Contents
Learn to Program with Visual Basic 2010 Express
Smiley Publishing
Chapter 1---Where Do I Begin?
Where Do We Begin
Programming the Easy Way
Planning a Program is Like Planning a House
We Receive a Call from the China Shop
We Meet with Our Client
The Systems Development Life Cycle (SDLC)
Phase 1: The Preliminary Investigation
Phase 2: Analysis
Phase 3: Design
Output Design
Input Design
Processing Design
Phase 4: Development
Phase 5: Implementation
Phase 6: Audit and Maintenance
Where To From Here?
Summary
Chapter 2---What Is a Computer Program?
Author's Note: Yes, I know this material is a bit dated. I was really tempted to pull it from the book, but it's classic material, and is still what's going on behind the scenes of your programs. If it's inclusion in the book compels you to believe I'm a dinosaur, and the book is worthless, so be it. But good programmers are by nature tinkerers---wanting to know what's happening behind the scenes. For that reason, I've kept it in the book. If you really hate it, just skip it, you won't miss anything.
What Is a Computer?
Data
Bits
Bytes
Memory
Computer Storage
RAM versus Storage
What Makes a Computer Program Run?
A Little Computer History
DOS
Booting DOS
Running Programs in DOS
C:\>WP
Bad Command or File name
RAM Use in DOS
Registers
The Stack
Problems with DOS
Microsoft Windows
The Title Bar
The Menu Bar
Windows Behavior
A More In-depth Look at Windows
Virtual Memory
Multitasking
Nonpreemptive Multitasking
Preemptive Multitasking
Running Programs in Windows
Preparing the Windows Program to Run
Running the Windows Program
The Windows Handle
Windows Messages
The Focus
What Is a Computer Program?
Summary
Chapter 3---Getting Comfortable With VB.Net
The VB.Net Environment
Preparing the Way for Programming
Let’s Start Up VB.Net!
The VB.Net Project
The IDE
The Modes of VB.Net
The VB.Net Menu Bar
The File Menu
The Print Menu
The Edit Menu
The View Menu
The Project Menu
The Build Menu
The Debug Menu
The Data Menu
The Format Menu
The Tools Menu
The Window Menu
The Help Menu
The VB.Net Toolbar
The VB.Net Toolbox
The Properties Window
Summary
Chapter 4---Programming Is Easy
Less Is Best
VB.Net Properties, Methods, and Events
VB.Net Properties
Running the China Shop Project for the First Time
Properties of the Form
Name of the Form
Naming Conventions
Height and Width Properties
The FormBorderStyle and ControlBox Properties
The StartPosition Property
The Text Property
VB.Net Methods
VB.Net Events
Me.Text = "I Love VB.Net"
MyBase.Text = "I Love VB.Net"
Summary
Chapter 5---Building the User Interface
Completing the User Interface
John Smiley’s Ten-Step Guide to Successful Interface Development
The VB.Net Toolbox
The China Shop Controls
Creation of the China Shop Form
The GroupBox Control
The ListBox Control
The Label Control
The Button Control
The CheckBox Control
The RadioButton Control
The PictureBox Control
The ColorDialog Control
The Timer Control
Let’s Run the China Shop Project!
Common Properties of the Controls in the China Shop Project
The Name Property
The Text Property
CheckBox Properties
Button Control Properties
The AcceptButton Property of the Form
The CancelButton Property of the Form
ColorDialog Properties
GroupBox Properties
PictureBox Control Properties
The SizeMode Property
Label Properties
The AutoSize Property
ListBox Properties
RadioButton Properties
Timer Properties
The Interval Property
Tab Order and the TabIndex Property
A Surprise Visit
Summary
Chapter 6---A First Look at Coding
Events and Event-Driven Programming
In the Old Days...
The Modern Approach
What’s an Event?
An Event or an Event Procedure?
An Example of an Event Procedure Stub
The Events in the China Shop Project
The Click Event
The Load Event
The SelectedIndexChanged Event
The Tick Event
Writing Code
Program Comments
The Line Continuation Character (_)
A VB.Net Code Overview
The Sequence Structure—Falling Rock
The Selection Structure
The Loop Structure
For intCounter = 1 to 10
The VB.Net Debugger
The Debug/Immediate Window
Pausing a VB.Net Program
The Break Button
Displaying Values in the Code Window
The Immediate Window
The Stop Statement
The Debug Menu
Step Into
Run To Cursor
Step Over
Step Out
Set Next
Show Next
The Locals Window
The Me Window
The Watch Window
Breakpoints
Summary
Chapter 7---Data
Computer Data
Variables
How Do We Create a Variable?
Variable Declaration
The Dim Statement
Declaring More than One Variable with one line of code
Variable Scope
The Private Statement
The Public Statement
Where Should You Declare a Variable?
Must Variables Be Initialized?
VB.Net Data Types
Numeric Data Types
Byte
Char
Short
Integer
Long
Single
Double
Decimal
The String Data Type
Other Data Types
Boolean
Date
Property Data Types
Constants
Operations on Data
Arithmetic Operations
The Addition Operator
The Subtraction Operator
The Multiplication Operator
The Integer Division Operator
The Floating-Point Division Operator
The Mod Operator
The Exponentiation Operator
Order of Operations
Comparison Operators
Logical Operators
The And Operator
The Or Operator
The Not Operator
How Not to Use Not
Summary
Chapter 8---Selection Structures
Falling Rock Behavior
How Can We Improve upon This?
If…Then
If…Then…Else
If…Then…ElseIf
Select...Case
The China Shop Project
Reviewing the Prototype
Summary
Chapter 9---Loops
Why Loops?
The For...Next Loop
Variations on the For...Next Theme
Do...Loops
Do While...Loop
Do...Loop While
Do Until...Loop
Do...Loop Until
Mr. Bullina Sends a Surprise
Summary
Chapter 10---String Manipulation
What Exactly Is a String?
String Concatenation
Breaking Strings Apart
Summary
Chapter 11---File Operations
Disk File Operations
Writing Data to a Disk File
The StreamWriter Object
The WriteLine Method
The Write Method
The Close Method
Reading Data from a Disk File
The ReadLine Method
Summary
Chapter 12---Finishing the User Interface
Where Are We Now?
Drop-Down Menus
A First Look at the MenuStrip Control
Adding Top-Level Menu Items
Adding Submenu Items
Deleting Menu Items
Inserting Menu Items
MenuItem Properties
Menu Item Events
Coding the Menu Item Controls
More on the MessageBox.Show Method
The Return Value of the MessageBox.Show Method
The Buttons Argument of the MessageBox.Show Method
The Icon Argument of the MessageBox.Show Method
Summary
Chapter 13---Arrays
Why Arrays?
What’s an Array?
Declaring an Array
Referring to Elements of an Array
Dynamic Arrays
Comma Delimited Files
Array Dimensions
Modifying the China Shop Project to Include Arrays
Summary
Chapter 14---Exception Handling
Common Beginner Errors
Referring to an Element Outside the Array Bounds
Forgetting to Increment a Counter Variable
Forgetting to Add to an Accumulator
Not providing a way for a while structure to end
Failing to include the Imports IO.Sys statement
Trying to Open a File For Reading That Does Not Exist
Forgetting to Close a File
Reading Too Many or Too Few Fields from a Disk File
Division by Zero
Exception Handling
VB.Net Exceptions
Ignore the Exception
Handle the Exception with Try-Catch-Finally Blocks
Exception Handling in the China Shop Project
Summary
Chapter 15---Customizing Your Program
Writing to the Windows Registry
Registry Keys and Subkeys
Using SetValue to write to the Windows Registry
Using RegEdit
Reading from the Windows Registry
Optimizing VB.Net Code
User-Written Procedures
Writing Our Own Procedures
Subprocedures in the China Shop Project
Testing Our Program
We Meet at the Bullina China Shop
Summary