ebook img

Beginning Visual Basic 2005 Express Edition: From Novice to Professional PDF

541 Pages·2006·20.263 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Beginning Visual Basic 2005 Express Edition: From Novice to Professional

CYAN YELLOW MAGENTA BLACK PANTONE 123 CV BOOKS FOR PROFESSIONALS BY PROFESSIONALS® THE EXPERT’S VOICE® IN.NET Companion eBook Available IInncclluuddeess MMiiccrroossoofftt Author of Beginning Visual Basic 2005 Express VViissuuaall BBaassiicc 22000055 ADO.NET:From Novice EExxpprreessss EEddiittiioonn to Pro,Visual Basic .NET Beginning Edition Edition: From Novice to Professional Beginning Visual Basic 6 V Beginning Visual Basic 6 Dear Reader, i Objects s In the 90s Microsoft did the impossible and released a programming tool that Beginning Beginning Visual Basic 5 u let everyone write programs to run on Windows. I was so excited about that Beginning Objects with tool, Visual Basic, that I wrote a series of books on it and introduced nearly a a Visual Basic 5 quarter of a million people all over the world to programming. l The Beginner’s Guide to Now Microsoft has done it again with the release of the Express tools. With B Visual Basic 2005 Visual Basic 4.0 nearly every home having a computer and most people having access to the a The Beginner’s Guide to Internet, being able to take control of the computer and write your own pro- Visual Basic 3 s grams is more useful and exciting than ever. So, I decided to do it again too. Beginning Visual C# 2005 In this book you’ll find everything you need to program your computer by i c Express Edition:From using Visual Basic 2005 Express, one of the very latest programming tools Novice to Professional Express Edition from Microsoft. I’ve even included Visual Basic 2005 Express on the CD in the 2 book, so this is a one-stop shop to get up to speed fast. If you have never written 0 computer programs before, I’ll show you how much fun and how easy it can be. 0 Perhaps you are a programmer and just need to get up to speed on .NET for work—this book is for you too. 5 I took the same approach with this book that I did with the VB ones, and E inside you’ll find a fast-paced guide to the essentials to get you programming fast. You’ll learn the Visual Basic 2005 language and the tools Visual Basic 2005 x Express provides. I cover everything from simple console programs to code that p From Novice to Professional talks to the Internet, and even how to write your own database programs. r Whatever your reasons for wanting to learn to program with Visual Basic, my e Join online discussions: book will get you where you want to be quickly, and hopefully with a smile on s forums.apress.com your face. So dive in and change the way you use computers forever. s FOR PROFESSIONALS Peter Wright BY PROFESSIONALS™ E d Companion eBook i THE APRESS ROADMAP t Beginning DotNetNuke 4.0 i o Website Creation in VB 2005 n Beginning Visual Basic Pro VB 2005 and the Expert VB 2005 See last page for details 2005 Express Edition .NET 2.0 Platform, 2E Business Objects, 2E on $10 eBook version Beginning Object-Oriented Programming with VB 2005 Peter Wright SOURCECODEONLINE INCLUDED www.apress.com ISBN 1-59059-622-6 52999 Wright US $29.99 Shelve in Programming User level: Beginner–Intermediate 6 89253 59622 7 9 781590 596227 this print for content only—size & color not accurate spine = 1.028" 544 page count 6226.book Page i Tuesday, August 29, 2006 8:22 PM Beginning Visual Basic 2005 Express Edition From Novice to Professional ■ ■ ■ Peter Wright 6226.book Page ii Tuesday, August 29, 2006 8:22 PM Beginning Visual Basic 2005 Express Edition: From Novice to Professional Copyright © 2006 by Peter Wright All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13 (pbk): 978-1-59059-622-7 ISBN-10 (pbk): 1-59059-622-6 Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1 Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Lead Editor: Jim Sumser Technical Reviewer: Jason Bock Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Jason Gilmore, Jonathan Gennick, Jonathan Hassell, James Huddleston, Chris Mills, Matthew Moodie, Dominic Shakeshaft, Jim Sumser, Keir Thomas, Matt Wade Associate Publisher, Production Director, and Project Manager: Grace Wong Copy Edit Manager: Nicole LeClerc Copy Editors: Sharon Wilkey, Ami Knox Assistant Production Director: Kari Brooks-Copony Senior Production Editor: Laura Cheu Compositor: Pat Christenson Proofreader: Nancy Riddiough Indexer: Broccoli Information Management Cover Designer: Kurt Krames Manufacturing Director: Tom Debolski Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail [email protected], or visit http://www.springeronline.com. For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA 94710. Phone 510-549-5930, fax 510-549-5939, e-mail [email protected], or visit http://www.apress.com. The information in this book is distributed on an “as is” basis, without warranty. Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work. The source code for this book is available to readers at http://www.apress.com in the Source Code section. You will need to answer questions pertaining to this book in order to successfully download the code. 6226.book Page iii Tuesday, August 29, 2006 8:22 PM Contents at a Glance About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xi About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii Acknowledgments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xiii Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv ■ CHAPTER 1 Welcome to VisualBasicExpress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 ■ CHAPTER 2 The Basics of Visual Basic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 ■ CHAPTER 3 Working with Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 ■ CHAPTER 4 Classes and Object Orientation in Visual Basic 2005. . . . . . . . . . . . 93 ■ CHAPTER 5 More-Advanced Object Orientation. . . . . . . . . . . . . . . . . . . . . . . . . . . 127 ■ CHAPTER 6 Handling Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 ■ CHAPTER 7 How Visual Basic 2005 Express Helps You Code . . . . . . . . . . . . . . 171 ■ CHAPTER 8 Building Windows Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 ■ CHAPTER 9 Windows and Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 ■ CHAPTER 10 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 ■ CHAPTER 11 Menus and Toolbars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 ■ CHAPTER 12 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 ■ CHAPTER 13 Lists and Generics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 ■ CHAPTER 14 Files and Streams. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359 ■ CHAPTER 15 Working with XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383 ■ CHAPTER 16 Database Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415 ■ CHAPTER 17 The Internet and Visual Basic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449 ■ CHAPTER 18 Threading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481 ■ CHAPTER 19 Where to Now? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497 ■ INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505 iii 6226.book Page iv Tuesday, August 29, 2006 8:22 PM 6226.book Page v Tuesday, August 29, 2006 8:22 PM Contents About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xi About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii Acknowledgments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xiii Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv ■ CHAPTER 1 Welcome to Visual Basic Express . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Just What Is Express? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Exploring the Visual Basic 2005 Express IDE. . . . . . . . . . . . . . . . . . . . . . . . . 4 Exploring the IDE a Little More . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Working with the Editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Writing Your Own Web Browser. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 ■ CHAPTER 2 The Basics of Visual Basic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 The Basic Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Source Code and the Two Project Types . . . . . . . . . . . . . . . . . . . . . . 37 Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 Inheritance and Polymorphism. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 Control Structures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 ■ CHAPTER 3 Working with Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 The Basic Basics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Numbers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Integers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Other Number Types. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 Boolean Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Characters and Text. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 Making Decisions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 If Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 Select Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 v 6226.book Page vi Tuesday, August 29, 2006 8:22 PM vi ■ CONTENTS Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 While Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 For Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 ■ CHAPTER 4 Classes and Object Orientation in Visual Basic 2005. . . . . 93 Classes and Objects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Creating Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 Using Constructors and Finalizers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Properties and Members. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 Getters and Setters. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 Scoping. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Public. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 Private. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 Shared. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 ■ CHAPTER 5 More-Advanced Object Orientation. . . . . . . . . . . . . . . . . . . . . . . 127 Inheritance. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 Virtual Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 Abstract Methods and Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134 Beware Shadows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 Casting Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 Reference Types and Value Types. . . . . . . . . . . . . . . . . . . . . . . . . . . 153 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 ■ CHAPTER 6 Handling Exceptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 Understanding Exceptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 Handling Exceptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 Bubbling Exceptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 Throwing Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 Custom Exceptions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 6226.book Page vii Tuesday, August 29, 2006 8:22 PM ■ CONTENTS vii ■ CHAPTER 7 How Visual Basic 2005 Express Helps You Code . . . . . . . . 171 Building a User Interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 Using Property Smart Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 Aligning Controls. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 Setting Tab Orders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 Using IntelliSense. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 Automatically Fixing Namespace Problems . . . . . . . . . . . . . . . . . . . 181 Using Code Snippets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 ■ CHAPTER 8 Building Windows Applications. . . . . . . . . . . . . . . . . . . . . . . . . . . 187 How Windows Programs Work. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 Common Properties and Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 Buttons in All Their Glory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 Entering Text. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 Text Boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 The MaskedTextBox Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 Adding ToolTip Help. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211 Choosing Things: Radio Buttons and Check Boxes . . . . . . . . . . . . . . . . . 215 Date Pickers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 ■ CHAPTER 9 Windows and Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 Windows (or Forms). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 The Main Window and How to Change It . . . . . . . . . . . . . . . . . . . . . 228 Opening and Closing Windows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229 Styles. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236 The Life and Times of a Form. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 MDI (Multiple Document Interface) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 Dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 Using a Simple Message Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 Creating Your Own Dialog Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 Common Dialogs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260 6226.book Page viii Tuesday, August 29, 2006 8:22 PM viii ■ CONTENTS ■ CHAPTER 10 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261 The ListBox Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262 The CheckedListBox Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 The ComboBox Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279 The TreeView Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 Changing the Visual Appearance of the Tree. . . . . . . . . . . . . . . . . . 285 Responding to Selections and Finding Nodes . . . . . . . . . . . . . . . . . 292 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 292 ■ CHAPTER 11 Menus and Toolbars. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 The Menu Controls. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 Building a Menu. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296 Adding Images and Shortcuts to a Menu . . . . . . . . . . . . . . . . . . . . . 299 Menus in an MDI Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 The Context Menu Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311 Toolbars and Status Bars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314 ■ CHAPTER 12 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 Hooking Events by Hand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 Creating Custom Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 ■ CHAPTER 13 Lists and Generics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329 Introducing Generics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331 Lists and SortedLists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346 Stacks and Queues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356 Creating Your Own Generics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358 6226.book Page ix Tuesday, August 29, 2006 8:22 PM ■ CONTENTS ix ■ CHAPTER 14 Files and Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359 Working with Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360 The FileSystemWatcher Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360 The File and Directory Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 Working with Streams. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 The Core Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 Working with File Streams. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 372 Working with Network Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 378 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 ■ CHAPTER 15 Working with XML. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383 System.Xml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384 Searching XML Documents. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389 Reading XML Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399 Writing XML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414 ■ CHAPTER 16 Database Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415 A Quick Walk-Through of the Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416 Exploring the Database Creation Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . 424 Writing Database Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 An Overview of Data Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448 ■ CHAPTER 17 The Internet and Visual Basic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449 Introducing the WebBrowser Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449 Working with the WebBrowser Control . . . . . . . . . . . . . . . . . . . . . . . 454 Accessing the Web Through Code . . . . . . . . . . . . . . . . . . . . . . . . . . 456 Handling Other Types of Data with WebClient. . . . . . . . . . . . . . . . . 465 Using Web Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.