Skip Navigation LinksLearn-VB-Contents

​​

Learn Visual Basic - Table of Contents


1. Introduction to the Visual Basic Environment

Preview 1-1
Course Objectives 1-2
What is Visual Basic? 1-3
Visual Basic vs. Visual Basic .NET vs. Visual Basic 1-5
A Brief Look at Object-Oriented Programming (OOP) 1-6
Structure of a Visual Basic Windows Application 1-7
Steps in Developing a Windows Application 1-9
Starting Visual Basic 1-10
Visual Basic Integrated Development Environment (IDE) 1-12
Saving a Visual Basic Project 1-20
Drawing the User Interface 1-21
Example 1-1: Stopwatch Application - Drawing Controls 1-24
Opening a Saved Visual Basic Project 1-25
Setting Properties of Controls at Design Time 1-26
Setting Properties at Run Time 1-29
How Names Are Used in Control Events 1-30
Use of Form Name Property 1-31
Example 1-2: Stopwatch Application - Setting Properties 1-33
Writing Code 1-35
Variables 1-39
Visual Basic Data Types 1-40
Variable Declaration 1-42
Arrays 1-45
Constants 1-46
Variable Initialization 1-47
Intellisense Feature 1-48
Example 1-3: Stopwatch Application - Writing Code 1-49
Class Review 1-53
Practice Problems 1 1-54
Problem 1-1. Beep Problem
Problem 1-2. Caption Problem
Problem 1-3. Enabled Problem
Problem 1-4. Date Problem
Exercise 1: Calendar/Time Display 1-55

2. The Visual Basic Language

Review and Preview 2-1
A Brief History of BASIC 2-2
Visual Basic Statements and Expressions 2-3
Strict Type Checking 2-5
Visual Basic Arithmetic Operators 2-7
Comparison and Logical Operators 2-9
Concatenation Operators 2-11
Visual Basic Functions 2-12
String Functions 2-13
String Class Methods 2-17
Dates and Times 2-21
Random Number Object 2-24
Math Functions 2-25
Example 2-1: Savings Account 2-27
Tab Stops and Tab Order 2-32
Example 2-2: Savings Accounts – Setting Tabs 2-35
Improving a Visual Basic Application 2-36
Visual Basic Decisions - If Statements 2-37
Select Case - Another Way to Branch 2-40
Key Trapping 2-42
Control Focus 2-44
Example 2-3: Savings Account - Key Trapping 2-45
Visual Basic Looping 2-49
Visual Basic Counting 2-53
Example 2-4: Savings Account - Decisions 2-55
Class Review 2-62
Practice Problems 2 2-63
Problem 2-1. Random Number Problem
Problem 2-2. Price Problem
Problem 2-3. Odd Integers Problem
Problem 2-4. Pennies Problem
Problem 2-5. Code Problem
Exercise 2-1: Computing a Mean and Standard Deviation 2-64
Exercise 2-2: Flash Card Addition Problems 2-65

3. Object-Oriented Programming (OOP)

Review and Preview 3-1
Introduction to Object-Oriented Programming (OOP) 3-2
Objects in Visual Basic 3-4
Adding a Class to a Visual Basic Project 3-5
Declaring and Constructing an Object 3-7
Adding Properties to a Class 3-8
How Visual Basic Puts Controls on a Form 3-10
Another Way to Add Properties to a Class 3-12
Validating Class Properties 3-13
Adding Constructors to a Class 3-15
Adding Methods to a Class 3-17
Inheritance 3-22
Example 3-1. Savings Account 3-29
Inheriting from Visual Basic Controls 3-36
Building a Custom Control 3-37
Adding New Properties to a Control 3-41
Adding Control Event Procedures and Methods 3-44
Example 3-2. Savings Account (Revisited) 3-47
Class Review 3-52
Practice Problems 3 3-53
Problem 3-1. Mortgage Problem
Problem 3-2. Accelerated Mortgage Problem
Problem 3-3. Flashing Label Problem
Exercise 3: Mailing List 3-54

4. Exploring the Visual Basic Toolbox

Review and Preview 4-1
Function Overloading 4-2
MessageBox Dialog 4-3
Form Object 4-8
Button Control 4-11
Label Control 4-13
TextBox Control 4-15
Example 4-1: Password Validation 4-18
CheckBox Control 4-23
RadioButton Control 4-25
GroupBox Control 4-27
Panel Control 4-29
Handling Multiple Events in a Single Procedure 4-31
Control Arrays 4-34
Example 4-2: Pizza Order 4-36
ListBox Control 4-44
ComboBox Control 4-47
Example 4-3: Flight Planner 4-49
Class Review 4-54
Practice Problems 4 4-56
Problem 4-1. Message Box Problem
Problem 4-2. Tray Problem
Problem 4-3. List Box Problem
Problem 4-4. Combo Box Problem
Exercise 4: Customer Database Input Screen 4-57

5. More Exploration of the Visual Basic Toolbox

Review and Preview 5-1
Control Z Order 5-2
NumericUpDown Control 5-3
DomainUpDown Control 5-5
Example 5-1: Date Input Device 5-7
Horizontal and Vertical ScrollBar Controls 5-10
TrackBar Control 5-14
Example 5-2: Temperature Conversion 5-16
Picture Box Control 5-21
OpenFileDialog Control 5-27
Example 5-3: Picture Box Playground 5-30
Legacy Controls 5-36
DriveListBox Control 5-38
DirListBox Control 5-39
FileListBox Control 5-40
Synchronizing the Drive, Directory, and File List Box Controls 5-42
Example 5-4: Image Viewer 5-44
Class Review 5-50
Practice Problems 5 5-51
Problem 5-1. Tic-Tac-Toe Problem
Problem 5-2. Number Guess Problem
Problem 5-3. File Times Problem
Exercise 5: Student Database Input Screen 5-52

6. Windows Application Design and Distribution

Review and Preview 6-1
Application Design Considerations 6-2
Multiple Form Visual Basic Applications 6-3
Adding a Module 6-6
Visual Basic Multiple Document Interface (MDI) 6-7
Example 6-1: Shopping Cart 6-8
Using General Procedures in Applications 6-22
Example 6-2: Circle Geometry 6-27
Using General Functions in Applications 6-31
Example 6-3: Average Value 6-33
MainMenu Control 6-39
ContextMenu Control 6-45
Font Object 6-46
FontDialog Control 6-47
Example 6-4: Note Editor 6-50
Distribution of a Visual Basic Application 6-56
Application Icons 6-59
Visual Basic Setup Wizard 6-62
Debug Versus Release Configuration 6-74
Building the Setup Program 6-75
Installing/Removing a Visual Basic Application 6-76
ClickOnce Deployment 6-79
Class Review 6-80
Practice Problems 6 6-77
Problem 6-1. Note Editor About Box Problem
Problem 6-2. Normal Numbers Problem
Problem 6-3. Context Menu Problem
Exercise 6: US/World Capitals Quiz 6-78

7. Sequential Files, Error-Handling and Debugging

Review and Preview 7-1
Sequential Files 7-2
Sequential File Output (Variables) 7-5
Application Path 7-10
Example 7-1: Writing Variables to Sequential Files 7-11
Sequential File Input (Variables) 7-15
Example 7-2: Reading Variables from Sequential Files 7-18
Parsing Data Lines 7-27
Example 7-3. Parsing Data Lines 7-29
Building Data Lines 7-33
Example 7-4: Building Data Lines 7-35
Configuration Files 7-40
Example 7-5: Configuration Files 7-42
Writing and Reading Text Using Sequential Files 7-45
SaveFileDialog Control 7-48
Example 7-6: Note Editor - Reading and Saving Text Files 7-51
StreamWriter Object 7-54
StreamReader Object 7-58
Error Handling 7-61
Run-Time Error Trapping and Handling 7-63
Example 7-7: Note Editor - Error Trapping 7-66
Debugging Visual Basic Programs 7-69
Example 7-8: Debugging Example 7-71
Using the Debugging Tools 7-74
Debugging Strategies 7-88
Class Review 7-89
Practice Problems 7 7-90
Problem 7-1. Option Saving Problem
Problem 7-2. Text File Problem
Problem 7-3. Data File Problem
Problem 7-4. Debugging Problem
Exercise 7-1: Information Tracking 7-92
Exercise 7-2: ‘Recent Files’ Menu Option 7-93

8. Graphics Techniques with Visual Basic

Review and Preview 8-1
Simple Animation 8-2
Example 8-1: Simple Animation 8-4
Timer Control 8-7
Example 8-2: Timer Control 8-9
Basic Animation 8-11
Example 8-3: Basic Animation 8-13
Random Numbers (Revisited) and Games 8-18
Example 8-4: One-Buttoned Bandit 8-20
Randomly Sorting Integers 8-28
Example 8-5: Random Integers 8-29
Graphics Methods 8-33
Graphics Object 8-34
Colors 8-36
ColorDialog Control 8-38
Pen Object 8-40
DrawLine Method 8-41
Graphics Methods (Revisited) 8-42
Persistent Graphics 8-45
Example 8-6: Drawing Lines 8-48
Rectangle Structure 8-52
DrawRectangle Method 8-54
Brush Object 8-55
FillRectangle Method 8-56
DrawEllipse Method 8-57
FillEllipse Method 8-58
Example 8-7: Drawing Rectangles and Ellipses 8-59
DrawPie Method 8-67
FillPie Method 8-69
Example 8-8: Drawing Pie Segments 8-71
Pie Charts 8-77
Line Charts and Bar Charts 8-81
Coordinate Conversions 8-84
Example 8-9: Line, Bar and Pie Charts 8-93
Class Review 8-102
Practice Problems 8 8-103
Problem 8-1. Find the Burger Game
Problem 8-2. Dice Rolling Problem
Problem 8-3. RGB Colors Problem
Problem 8-4. Plotting Problem
Problem 8-5. Pie Chart Problem
Exercise 8-1: Blackjack 8-104
Exercise 8-2: Information Tracking Plotting 8-105

9. More Graphics Methods and Multimedia Effects

Review and Preview 9-1
Mouse Events 9-2
Example 9-1: Blackboard 9-5
Persistent Graphics, Revisited (Image and Bitmap Objects) 9-14
Example 9-2: Blackboard (Revisited) 9-17
More Graphics Methods 9-20
Point Structure 9-21
DrawLines Method 9-22
DrawPolygon Method 9-24
FillPolygon Method 9-25
DrawCurve Method 9-26
DrawClosedCurve Method 9-27
FillClosedCurve Method 9-28
Example 9-3: Drawing Lines, Polygons, Curves, Closed Curves 9-31
Example 9-4: Drawing Animated Lines and Curves 9-38
HatchBrush Object 9-41
Example 9-5: Hatch Brush 9-43
LinearGradientBrush Object 9-45
Example 9-6: Linear Gradient Brush 9-47
TextureBrush Object 9-49
Example 9-7: Texture Brush 9-50
DrawString Method 9-52
Multimedia Effects 9-57
Animation with DrawImage Method 9-58
Example 9-8: Bouncing Ball 9-60
Scrolling Backgrounds 9-66
Example 9-9: Horizontally Scrolling Background 9-69
Sprite Animation 9-73
Keyboard Events 9-76
Example 9-10. Sprite Animation 9-78
Collision Detection 9-83
Example 9-11: Collision Detection 9-84
Playing Sounds 9-89
Example 9-12: Bouncing Ball with Sound! 9-91
Class Review 9-93
Practice Problems 9 9-94
Problem 9-1. Blackboard Problem
Problem 9-2. Rubber Band Problem
Problem 9-3. Shape Guessing Game
Problem 9-4. Plot Labels Problem
Problem 9-5. Bouncing Balls Problem
Problem 9-6. Moon Problem
Problem 9-7. Sound File Problem
Exercise 9: The Original Video Game - Pong! 9-95

10. Other Windows Application Topics

Review and Preview 10-1
Other Controls 10-2
LinkLabel Control 10-3
Example 10-1: Link Label Control 10-5
TabControl Control 10-7
Example 10-2: Tab Control 10-10
MonthCalendar Control 10-17
DateTimePicker Control 10-19
Example 10-3: Date Selections 10-20
RichTextbox Control 10-23
Example 10-4: Rich Text Box Example 10-26
ToolBar (Toolstrip) Control 10-29
Example 10-5: Note Editor Toolbar 10-33
ToolTip Control 10-38
Example 10-6: Tool Tip Control 10-39
Adding Controls at Run-Time 10-41
Example 10-7: Rolodex – Adding Controls at Run-Time 10-43
Printing with Visual Basic 10-46
Printing Pages of a Document 10-49
PageSetupDialog Control 10-55
PrintDialog Control 10-58
PrintPreviewDialog Control 10-60
Example 10-8: Printing 10-62
Using the Windows API 10-69
Timing with the Windows API 10-71
Example 10-9. Stopwatch Application (Revisited) 10-73
Adding a Help System to Your Application 10-75
Creating a Help File 10-77
Starting HTML Help Workshop 10-78
Creating Topic Files 10-80
Creating Table of Contents File 10-83
Compiling the Help File 10-88
HelpProvider Control 10-91
Example 10-10: Help System Display 10-93
Class Review 10-95
Practice Problems 10 10-96
Problem 10-1. Biorhythm Problem
Problem 10-2. Rich Textbox Note Editor Problem
Problem 10-3. Loan Printing Problem
Problem 10-4. Plot Printing Problem
Problem 10-5. Sound Timing Problem
Problem 10-6. Note Editor Help Problem
Exercise 10: Phone Directory 10-98

11. Visual Basic Database Applications

Review and Preview 11-1
Database Applications 11-2
Database Structure and Terminology 11-3
DataSet Objects 11-7
Simple Data Binding 11-16
Database Navigation 11-18
Example 11-1: Accessing the Books Database 11-19
Creating a Virtual Table 11-25
Example 11-2: Creating a Virtual Table 11-26
DataView Objects 11-35
Example 11-3: ‘Rolodex’ Searching of the Books Database 11-38
Complex Data Binding 11-42
Web Applications 11-48
Starting a New Web Application 11-50
Web Form Controls 11-53
Building a Web Application 11-60
Example 11-4: Loan Payments 11-63
Example 11-5: Loan Repayment Schedule 11-69
Class Review 11-47
Course Summary 11-48
Practice Problems 11 11-49
Problem 11-1. New DataView Problem
Problem 11-2. Multiple Authors Problem
Problem 11-3. Stopwatch Problem
Exercise 11: The Ultimate Application 11-75

Practice Problems Solutions (Part 1: Classes 1 to 6) P1-1
Practice Problems Solutions (Part 2: Classes 7 to 11) P2-1
Exercise Solutions (Part 1: Classes 1 to 6) E1-1
Exercise Solutions (Part 2: Classes 7 to 11) E2-1​