Teach yourself the fundamentals of working with Visual Basic 2008—one step at a time. With STEP BY STEP, you work at your own pace through hands-on, learn-by-doing exercises. Whether you’re a beginning programmer or new to this specific language, you’ll understand the core capabilities and fundamental techniques for Visual Basic 2008—and rapidly build robust, elegant applications. Each chapter puts you to work, showing you how, when, and why to use the latest features of Visual Basic—guiding you each step of the way as you create actual components and working applications for Windows. You’ll also explore data management and Web-based development topics. PLUS—get practice files with sample code and data sets on the companion CD.
Getting Started with Microsoft Visual Basic 2008
Chapter 1 Exploring the Visual Studio Integrated Development Environment
The Visual Studio Development Environment
The Visual Studio Tools
The Properties Window
Moving and Resizing the Programming Tools
Switching Among Open Files and Tools by Using the IDE Navigator
Opening a Web Browser Within Visual Studio
Getting Help
Customizing IDE Settings to Match Step-by-Step Exercises
One Step Further: Exiting Visual Studio
Quick Reference
Chapter 2 Writing Your First Program
Lucky Seven: Your First Visual Basic Program
Programming Steps
Creating the User Interface
Setting the Properties
The Picture Box Properties
Writing the Code
A Look at the Button1_Click Procedure
Running Visual Basic Applications
Sample Projects on Disk
Building an Executable File
Deploying Your Application
One Step Further: Adding to a Program
Quick Reference
Chapter 3 Working with Toolbox Controls
The Basic Use of Controls: The Hello World Program
Using the DateTimePicker Control
Controls for Gathering Input
One Step Further: Using the LinkLabel Control
Quick Reference
Chapter 4 Working with Menus, Toolbars, and Dialog Boxes
Adding Menus by Using the MenuStrip Control
Adding Access Keys to Menu Commands
Processing Menu Choices
Adding Toolbars with the ToolStrip Control
Using Dialog Box Controls
Event Procedures That Manage Common Dialog Boxes
One Step Further: Assigning Shortcut Keys to Menus
Quick Reference
Programming Fundamentals
Chapter 5 Visual Basic Variables and Formulas, and the .NET Framework
The Anatomy of a Visual Basic Program Statement
Using Variables to Store Information
Using Variables in a Program
Using a Variable to Store Input
Using a Variable for Output
Working with Specific Data Types
Working with Visual Basic Operators
Working with Methods in the Microsoft .NET Framework
One Step Further: Establishing Order of Precedence
Quick Reference
Chapter 6 Using Decision Structures
Event-Driven Programming
Using Conditional Expressions
If…Then Decision Structures
Select Case Decision Structures
One Step Further: Detecting Mouse Events
Quick Reference
Chapter 7 Using Loops and Timers
Writing For…Next Loops
Displaying a Counter Variable in a TextBox Control
Creating Complex For…Next Loops
Writing Do Loops
Avoiding an Endless Loop
The Timer Control
Creating a Digital Clock by Using a Timer Control
Using a Timer Object to Set a Time Limit
One Step Further: Inserting Code Snippets
Quick Reference
Chapter 8 Debugging Visual Basic Programs
Finding and Correcting Errors
Three Types of Errors
Identifying Logic Errors
Debugging 101: Using Debugging Mode
Tracking Variables by Using a Watch Window
Visualizers: Debugging Tools That Display Data
Using the Immediate and Command Windows
Switching to the Command Window
One Step Further: Removing Breakpoints
Quick Reference
Chapter 9 Trapping Errors by Using Structured Error Handling
Processing Errors by Using the Try…Catch Statement
Writing a Disc Drive Error Handler
Using the Finally Clause to Perform Cleanup Tasks
More Complex Try…Catch Error Handlers
Comparing Error Handlers with Defensive Programming Techniques
One Step Further: The Exit Try Statement
Quick Reference
Chapter 10 Creating Modules and Procedures
Working with Modules
Working with Public Variables
Creating Procedures
Writing Function Procedures
Writing Sub Procedures
One Step Further: Passing Arguments by Value and by Reference
Quick Reference
Chapter 11 Using Arrays to Manage Numeric and String Data
Working with Arrays of Variables
Preserving Array Contents by Using ReDim Preserve
One Step Further: Processing Large Arrays by Using Methods in the Array Class
Quick Reference
Chapter 12 Working with Collections and the System.Collections Namespace
Working with Object Collections
Creating Your Own Collections
One Step Further: VBA Collections
Quick Reference
Chapter 13 Exploring Text Files and String Processing
Displaying Text Files by Using a Text Box Object
Using the StreamReader Class and My.Computer.FileSystem to Open Text Files
Creating a New Text File on Disk
Processing Text Strings with Program Code
One Step Further: Examining the Sort Text Program Code
Quick Reference
Designing the User Interface
Chapter 14 Managing Windows Forms and Controls at Run Time
Adding New Forms to a Program
How Forms Are Used
Working with Multiple Forms
Positioning Forms on the Windows Desktop
Adding Controls to a Form at Run Time
Organizing Controls on a Form
One Step Further: Specifying the Startup Object
Quick Reference
Chapter 15 Adding Graphics and Animation Effects
Adding Artwork by Using the System.Drawing Namespace
Adding Animation to Your Programs
Expanding and Shrinking Objects While a Program Is Running
One Step Further: Changing Form Transparency
Quick Reference
Chapter 16 Inheriting Forms and Creating Base Classes
Inheriting a Form by Using the Inheritance Picker
Creating Your Own Base Classes
One Step Further: Inheriting a Base Class
Quick Reference
Chapter 17 Working with Printers
Using the PrintDocument Class
Printing Multipage Text Files
One Step Further: Adding Print Preview and Page Setup Dialog Boxes
Quick Reference
Database and Web Programming
Chapter 18 Getting Started with ADO.NET
Database Programming with ADO.NET
Using Bound Controls to Display Database Information
One Step Further: SQL Statements, LINQ, and Filtering Data
Quick Reference
Chapter 19 Data Presentation Using the DataGridView Control
Using DataGridView to Display Database Records
Formatting DataGridView Cells
Datacentric Focus:Adding a Second Grid and Navigation Control
One Step Further: Updating the Original Database
Quick Reference
Chapter 20 Creating Web Sites and Web Pages by Using Visual Web Developer and ASP.NET
Inside ASP.NET
Building a Web Site by Using Visual Web Developer
Using the Web Page Designer
Adding Server Controls to a Web Site
Adding Additional Web Pages and Resources to a Web Site
Displaying Database Records on a Web Page
One Step Further: Setting the Web Site Title in Internet Explorer
Quick Reference
Appendix Where to Go for More Information
Visual Basic Web Sites
Books About Visual Basic and Visual Studio Programming
Michael Halvorson has written more than 30 books, including the popular Microsoft Visual Basic 2008 Step by Step, Microsoft Office XP Inside Out, and Microsoft Visual Basic 6.0 Professional Step by Step. A former Visual Basic localization manager at Microsoft, Michael is a professor at Pacific Lutheran University.