Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Visual Basic 2005 express edition for dummies
Nội dung xem thử
Mô tả chi tiết
by Richard Mansfield
Visual Basic® 2005
Express Edition
FOR
DUMmIES‰
01_597051 ffirs.qxd 10/20/05 1:17 PM Page iii
Visual Basic® 2005
Express Edition
FOR
DUMmIES‰
01_597051 ffirs.qxd 10/20/05 1:17 PM Page i
01_597051 ffirs.qxd 10/20/05 1:17 PM Page ii
by Richard Mansfield
Visual Basic® 2005
Express Edition
FOR
DUMmIES‰
01_597051 ffirs.qxd 10/20/05 1:17 PM Page iii
Visual Basic® 2005 Express Edition For Dummies®
Published by
Wiley Publishing, Inc.
111 River Street
Hoboken, NJ 07030-5774
www.wiley.com
Copyright © 2006 by Wiley Publishing, Inc., Indianapolis, Indiana
Published by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or
by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written
permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the
Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600.
Requests to the Publisher for permission should be addressed to the Legal Department, Wiley Publishing,
Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at
http://www.wiley.com/go/permissions.
Trademarks: Wiley, the Wiley Publishing logo, For Dummies, the Dummies Man logo, A Reference for the
Rest of Us!, The Dummies Way, Dummies Daily, The Fun and Easy Way, Dummies.com, and related trade
dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates in the United
States and other countries, and may not be used without written permission. Visual Basic is a registered
trademark of Microsoft Corporation in the United States and/or other countries. All other trademarks are
the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or
vendor mentioned in this book.
LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT
LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE
UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR
OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A
COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE
AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION
OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE.
FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE
CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.
For general information on our other products and services, please contact our Customer Care
Department within the U.S. at 800-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002.
For technical support, please visit www.wiley.com/techsupport.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may
not be available in electronic books.
Library of Congress Control Number: 2005927625
ISBN-13: 978-0-7645-9705-3
ISBN-10: 0-7645-9705-1
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
1B/QZ/RR/QV/IN
01_597051 ffirs.qxd 10/20/05 1:17 PM Page iv
About the Author
Richard Mansfield’s recent titles include Office 2003 Application Development
All-in-One Desk Reference For Dummies, CSS Web Design For Dummies, Visual
Basic .NET Weekend Crash Course, Visual Basic .NET Database Programming
For Dummies, Visual Basic .NET All-in-One Desk Reference For Dummies, and
Visual Basic 6 Database Programming For Dummies (all from Wiley).
From 1981 through 1987, he was editor of COMPUTE! Magazine, during which
time he wrote hundreds of magazine articles and two columns. From 1987 to
1991, he was editorial director and partner in Signal Research and began writing books full-time in 1991. He has written 37 computer books since 1982. Of
those, four became bestsellers: Machine Language for Beginners (COMPUTE!
Books), The Second Book of Machine Language (COMPUTE! Books), The
Visual Guide to Visual Basic (Ventana), and The Visual Basic Power Toolkit
(Ventana, with Evangelos Petroutsos). Overall, his books have sold more than
500,000 copies worldwide and have been translated into 11 languages.
01_597051 ffirs.qxd 10/20/05 1:17 PM Page v
01_597051 ffirs.qxd 10/20/05 1:17 PM Page vi
Dedication
This book is dedicated to my mother, Florence Mansfield.
01_597051 ffirs.qxd 10/20/05 1:17 PM Page vii
01_597051 ffirs.qxd 10/20/05 1:17 PM Page viii
Author’s Acknowledgments
I’d like to thank the following people for their contributions to this book.
Acquisitions Editor Katie Feltman is always a pleasure to work with —
knowledgeable, enthusiastic, and good with authors (at least this one, anyway).
Project Editor Becky Huehls also deserves praise for her thoroughgoing edit,
and the many improvements to the book that resulted.
Technical Editor John Mueller is a highly regarded author in the computer
book field (and a friend, and coauthor of previous titles with me). I feel lucky
that he agreed to review my manuscript for errors in both the code and the
concepts. His considerable depth of knowledge contributed to the quality of
the book. If you disagree with some of my technical or theoretical observations, assume that John did too, but I wasn’t wise enough to take his advice
and change my remarks.
I also want to thank Copy Editor Andy Hollandbeck for making many improvements. Andy not only knows how to write good English, he’s also more familiar than most copy editors with computer programming. Plus, he seems like a
good guy in the bargain. Happily, Andy seems to have pretty balanced views
about the great serial comma debate, and the current conflict over gerunds.
To these, and all the good people at Wiley who contributed in so many additional ways to this book, my thanks for the time and care they took to ensure
its quality every step along the way from original idea to final publication.
01_597051 ffirs.qxd 10/20/05 1:17 PM Page ix
Publisher’s Acknowledgments
We’re proud of this book; please send us your comments through our online registration form
located at www.dummies.com/register/.
Some of the people who helped bring this book to market include the following:
Acquisitions, Editorial, and
Media Development
Project Editor: Rebecca Huehls
Acquisitions Editor: Katie Feltman
Copy Editor: Andy Hollandbeck
Technical Editor: John Mueller
Editorial Manager: Leah Cameron
Permissions Editor: Laura Moss
Media Development Specialist: Travis Silvers
Media Development Manager:
Laura VanWinkle
Media Development Supervisor:
Richard Graves
Editorial Assistant: Amanda Foxworth
Cartoons: Rich Tennant (www.the5thwave.com)
Composition Services
Project Coordinators: Adrienne Martinez,
Kathryn Shanks
Layout and Graphics: Carl Byers,
Andrea Dahl, Lauren Goddard,
Stephanie D. Jumper, Barry Offringa,
Mary Gillot Virgin
Proofreaders: Leeann Harney,
Carl William Pierce, TECHBOOKS
Production Services
Indexer: TECHBOOKS Production Services
Publishing and Editorial for Technology Dummies
Richard Swadley, Vice President and Executive Group Publisher
Andy Cummings, Vice President and Publisher
Mary Bednarek, Executive Acquisitions Director
Mary C. Corder, Editorial Director
Publishing for Consumer Dummies
Diane Graves Steele, Vice President and Publisher
Joyce Pepple, Acquisitions Director
Composition Services
Gerry Fahey, Vice President of Production Services
Debbie Stailey, Director of Composition Services
01_597051 ffirs.qxd 10/20/05 1:17 PM Page x
Contents at a Glance
Introduction ................................................................1
Part I: The Basics of Visual Basic Express ....................11
Chapter 1: What It’s All About: Visual Basic Express Takes a Bow ...........................13
Chapter 2: Up and Running ............................................................................................23
Chapter 3: At Your Service: Loads of Built-In Helpers ................................................35
Chapter 4: Tackling Essential Tools ..............................................................................51
Part II: Programming the Practical Way ......................75
Chapter 5: Common Tasks .............................................................................................77
Chapter 6: It’s All about My ............................................................................................97
Chapter 7: Whose Type Are You: Managing Variable Types ....................................105
Chapter 8: Superstrings: Managing Arrays ................................................................129
Chapter 9: Pretty Printing ............................................................................................143
Chapter 10: Testing and Deployment ..........................................................................161
Part III: Dealing with Databases ...............................179
Chapter 11: The Basics of Databases ..........................................................................181
Chapter 12: Quick Database User-Interface Techniques ..........................................191
Chapter 13: Managing DataSets ...................................................................................209
Part IV: Programming for the Web ............................225
Chapter 14: Painless Internet Programming ..............................................................227
Chapter 15: Everything’s Eventual: Web Page Management ....................................245
Part V: The Part of Tens ...........................................263
Chapter 16: Ten Great Visual Basic Express Tips and Tricks ..................................265
Chapter 17: Ten Important VB Resources ..................................................................277
Appendix A: About the CDs .......................................283
Bonus Appendix B: A Dictionary of VB.NET ....On the Web
Index .......................................................................287
02_597051 ftoc.qxd 10/20/05 1:18 PM Page xi
02_597051 ftoc.qxd 10/20/05 1:18 PM Page xii
Table of Contents
Introduction ..................................................................1
Understanding Visual Basic ............................................................................2
Tapping into the Power ...................................................................................2
About This Book ...............................................................................................3
How to Use This Book ......................................................................................4
Foolish Assumptions ........................................................................................5
How This Book Is Organized ...........................................................................6
Part I: The Basics of Visual Basic Express ...........................................6
Part II: Programming the Practical Way ...............................................6
Part III: Dealing with Databases ............................................................6
Part IV: Programming for the Web ........................................................7
Part V: The Part of Tens .........................................................................7
Appendixes ..............................................................................................7
Conventions Used in This Book .....................................................................8
What You Need to Get Started ........................................................................8
Icons Used in This Book ..................................................................................9
Where to Go from Here ....................................................................................9
Part I: The Basics of Visual Basic Express .....................11
Chapter 1: What It’s All About: Visual Basic Express Takes a Bow . . .13
Something Strange Happened in Orlando ...................................................14
Visual Basic through the years ...........................................................14
Visual Basic today ................................................................................15
What Does Visual Basic Express Have to Offer? ........................................15
Defaults that serve a purpose .............................................................16
The Express initiatives .........................................................................16
Finding help ...........................................................................................18
Taking a First Look .........................................................................................19
Creating a user interface helps organize your project ....................20
Programming for the Web ....................................................................21
Chapter 2: Up and Running . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
Finding Resources from Microsoft ...............................................................23
Building a Basic VB Program ........................................................................24
02_597051 ftoc.qxd 10/20/05 1:18 PM Page xiii