--------------------------------------------------------------------------------
Acknowledgments xi
Introduction xiii
PART 1
GETTING STARTED WITH MICROSOFT VISUAL BASIC .NET 2003
CHAPTER 1
Opening and Running a Visual Basic .NET 2003 Program 3
The Visual Studio .NET Development Environment
5
The Visual Studio .NET Tools
10
The Windows Forms Designer
12
Running a Visual Basic Program
14
The Properties Window
16
Moving and Resizing the Programming Tools
20
Moving and Resizing Tool Windows in Visual Studio
21
Docking a Tool in Visual Studio
23
Hiding a Tool in Visual Studio
25
Getting Help
27
One Step Further: Exiting Visual Studio .NET
30
CHAPTER 2
Writing Your First Program
33
Lucky Seven: Your First Visual Basic .NET Program
34
Programming Steps
35
Creating the User Interface
35
Setting the Properties
42
The Picture Box Properties
47
Writing the Code
49
A Look at the Button1--Click Procedure
54
Running Visual Basic .NET Applications
56
Building an Executable File
58
One Step Further: Adding to a Program
60
CHAPTER 3
Working with Toolbox Controls
63
The Basic Use of Controls: The 'Hello World' Program
64
Using the DateTimePicker Control
70
The Birthday Program
70
Controls for Gathering Input
77
The Input Controls Demo
80
Looking at the Input Controls Program Code
83
Using the LinkLabel Control
86
One Step Further: Installing ActiveX Controls
91
The Microsoft Chart Control
91
CHAPTER 4
Working with Menus and Dialog Boxes
95
Adding Menus Using the MainMenu Control
96
Adding Access Keys to Menu Commands
98
Processing Menu Choices
101
Using Dialog Box Controls
106
Changing the Object Names for Items on the File Menu
109
Disabling a Menu Command
110
Event Procedures That Manage Common Dialog Boxes
111
One Step Further: Assigning Shortcut Keys to Menus
118
PART 2
PROGRAMMING FUNDAMENTALS
CHAPTER 5
Visual Basic .NET Variables and Operators
125
The Anatomy of a Visual Basic Program Statement
127
Using Variables to Store Information
127
Setting Aside Space for Variables: The Dim Statement
128
Using Variables in a Program
129
Using a Variable to Store Input
133
Using a Variable for Output
136
Working with Specific Data Types
138
Constants: Variables That Don't Change
144
Working with Visual Basic Operators
146
Basic Math: The +, -, *, and / Operators
146
Using Advanced Operators: \, Mod, ^, and & 150
Working with Math Methods in the .NET Framework
155
Operator Precedence
157
One Step Further: Using Parentheses in a Formula
158
CHAPTER 6
Using Decision Structures
161
Event-Driven Programming
162
Using Conditional Expressions
164
If--Then Decision Structures
165
Testing Several Conditions in an If...Then Decision Structure
165
Using Logical Operators in Conditional Expressions
170
Short-Circuiting by Using AndAlso and OrElse
172
Select Case Decision Structures
174
Using Comparison Operators with a Select Case Structure
176
One Step Further: Detecting Mouse Events
180
CHAPTER 7
Using Loops and Timers
185
Writing For--Next Loops
186
Displaying a Counter Variable in a TextBox Control
187
Creating Complex For--Next Loops
190
Opening Files Using a Counter That Has Greater Scope
193
Writing Do Loops
196
Avoiding an Endless Loop
197
The Timer Control
201
Creating a Digital Clock Using a Timer Control
201
One Step Further: Using a Timer Object to Set a Time Limit
204
CHAPTER 8
Debugging Visual Basic .NET Programs
209
Finding and Correcting Errors
210
Three Types of Errors
210
Identifying Logic Errors
212
Debugging 101: Using Break Mode
212
Tracking Variables by Using a Watch Window
218
Using the Command Window
220
Switching to Command Mode in the Command Window
222
One Step Further: Removing Breakpoints
223
CHAPTER 9
Trapping Errors Using Structured Error Handling
225
Processing Errors Using Try...Catch
226
When to Use Error Handlers
227
Setting the Trap: The Try...Catch Statement
228
Path and Disk Drive Errors
228
Writing a Disk Drive Error Handler
231
Using the Finally Clause to Perform Cleanup Tasks
232
More Complex Try...Catch Error Handlers
234
The Err Object
234
Specifying a Retry Period
238
Using Nested Try...Catch Blocks
241
Comparing Error Handlers with Defensive Programming Techniques
241
One Step Further: The Exit Try Statement
242
PART 3
MANAGING CORPORATE DATA
CHAPTER 10
Using Modules and Procedures
249
Working with Standard Modules
251
Creating a Standard Module
251
Working with Public Variables
254
Creating Procedures
259
Writing Function Procedures
260
Function Syntax
260
Calling a Function Procedure
262
Using a Function to Perform a Calculation
262
Writing Sub Procedures
266
Sub Procedure Syntax
266
Calling a Sub Procedure
267
Using a Sub Procedure to Manage Input
268
One Step Further: Passing Arguments by Value and by Reference
273
Which to Use: ByVal or ByRef?
274
CHAPTER 11
Using Arrays and Collections to Manage Data
277
Working with Arrays of Variables
278
Creating an Array
279
Declaring a Fixed-Size Array
280
Working with Array Elements
281
Creating a Fixed-Size Array to Hold Temperatures
282
Creating a Dynamic Array
286
Preserving Array Contents by Using ReDim Preserve
289
Working with Object Collections
291
Referencing Objects in a Collection
292
Writing For Each...Next Loops
292
Experimenting with Objects in the Controls Collection
293
Using the Name Property in a For Each...Next Loop
296
Creating Your Own Collections
298
One Step Further: Visual Basic for Applications Collections
302
CHAPTER 12
Exploring Text Files and String Processing 307
Displaying Text Files by Using a Text Box Object 308
Opening a Text File for Input 309
The FileOpen Function 309
Creating a New Text File on Disk 315
Processing Text Strings with Program Code 319
Processing Strings by Using Methods and Keywords 319
Sorting Text 321
Working with ASCII Codes 322
Sorting Strings in a Text Box 323
Protecting Text with Encryption 329
One Step Further: Using the Xor Operator 333
Examining the Encryption Code 335
CHAPTER 13
Automating Microsoft Office Applications and Managing Processes 341
Programming Application Objects by Using Automation 342
Using Automation in Visual Basic 343
The Visual Studio Object Browser 344
Automating Excel from Visual Basic 348
One Step Further: Starting and Stopping Windows Applications by Using the Process Component 356
CHAPTER 14
Deploying Visual Basic .NET Applications 361
Planning a Deployment 362
Different Ways to Deploy an Application 364
Creating a Deployment Project 365
Customizing Your Deployment Options 375
Building a Deployment Project and Testing Setup 381
One Step Further: Examining Setup Files and Uninstalling 386
PART 4
ADVANCED USER INTERFACE DESIGN
CHAPTER 15
Managing Windows Forms
393
Adding New Forms to a Program 394
How Forms Are Used 395
Working with Multiple Forms 396
Positioning Forms on the Windows Desktop 403
Minimizing, Maximizing, and Restoring Windows 408
Adding Controls to a Form at Runtime 409
Organizing Controls on a Form 412
One Step Further: Specifying the Startup Object 415
CHAPTER 16
Adding Graphics and Animation Effects
421
Adding Artwork by Using the System.Drawing Namespace
422
Using a Form's Coordinate System
423
The System.Drawing.Graphics Class
424
Using the Form's Paint Event
425
Adding Animation to Your Programs
427
Moving Objects on the Form
428
The Location Property
429
Creating Animation by Using a Timer Object
430
Expanding and Shrinking Objects While a Program Is Running
434
One Step Further: Changing Form Transparency
436
CHAPTER 17
Inheriting Forms and Creating Base Classes
439
Inheriting a Form by Using the Inheritance Picker
440
Creating Your Own Base Classes
445
Adding a New Class to Your Project
446
One Step Further: Inheriting a Base Class
453
CHAPTER 18
Working with Printers
459
Using the PrintDocument Class
460
Printing Text from a Text Box Object
465
Printing Multipage Text Files
469
One Step Further: Adding Print Preview and Page Setup Dialog Boxes
476
PART 5
DATABASE PROGRAMMING
CHAPTER 19
Getting Started with ADO.NET
487
Database Programming with ADO.NET
488
Database Terminology
489
Working with an Access Database
490
Creating a Data Adapter
494
Working with Datasets
499
Using Bound Controls to Display Database Information on a Form
501
Creating Navigation Controls
505
One Step Further: Displaying the Current Record Position
509
CHAPTER 20
Data Presentation Using the DataGrid Control
513
Using DataGrid to Display Database Records
514
Formatting DataGrid Cells
523
One Step Further: Updating the Original Database
525
PART 6
INTERNET PROGRAMMING
CHAPTER 21
Displaying HTML Documents Using Internet Explorer
531
Getting Started with the Internet Explorer Object
532
Adding the Microsoft Internet Controls Reference to Your Application
533
Investigating the Internet Explorer Object Model
534
Displaying HTML Documents
537
One Step Further: Responding to Internet Explorer Events
541
CHAPTER 22
Using Web Forms to Build Interactive Web Applications
545
Inside ASP.NET
546
Web Forms vs. Windows Forms
547
HTML Controls
548
Web Forms Controls
549
Getting Started with a Web Application
550
Installing the Software for ASP.NET Programming
550
Using the Web Forms Designer
556
Adding Web Forms Controls to a Web Application
559
Writing Event Procedures for Web Forms Controls
561
One Step Further: Creating a Link to Another Web Page
565
PART 7
APPENDIXES
APPENDIX A
Upgrading Visual Basic 6 Programs to Visual Basic .NET 2003 573
Assessing Visual Basic 6 Programs for Compatibility 574
Problematic Issues 575
Internet Resources for Migration 576
Upgrade Steps 577
Running the Visual Basic Upgrade Wizard 577
APPENDIX B
Where to Go for More Information 587
Visual Basic .NET Web Sites 587
http://msdn.microsoft.com/vbasic/
588
http://www.devx.com/
588
http://www.microsoft.com/mspress/
588
http://www.microsoft.com/traincert/
588
http://communities2.microsoft.com/home/
589
Books for Visual Basic .NET Programming 589
Visual Basic .NET Programming 589
Web Programming with ASP .NET 590
Database Programming with ADO.NET 590
Visual Basic for Applications Programming 590
UPGRADING INDEX 591
INDEX 597