the book of visual basic 2005 - .net insight for classic vb developers

508 385 0
the book of visual basic 2005 - .net insight for classic vb developers

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

From the author of the highly acclaimed Book ofVB .NET comes this comprehensive introduction to Visual Basic 2005, the newest version of Microsoft’s popular programming language. If you’re a developer who is new to the language, you will learn to use VB 2005 effectively. If you’re from the old school of VB but haven’t yet made the jump to .NET, you will be able to make the transition seamlessly. And you won’t have to wade through boring, unnecessary material before you get there. This guide covers all the necessities, ditching jargon and getting right to the substance of how to: • Implement object-oriented programming with classes, interfaces, and inheritance • Design well-behaved multithreaded applications • Work with XML, file streams, and ADO.NET, the .NET toolkit for relational databases • Build code-driven web pages and rich Windows applications • Deploy your applications with snazzy setup programs Conversational in tone and eminently readable, this book tackles VB 2005’s hot new features and explains how to work with .NET, but it doesn’t water the informa- tion down for beginners. After a brief overview of changes from VB 6, you’ll get real-world examples in each chapter that will get you up to speed and ready to perform in the VB 2005 environment. Helpful code examples, references to additional online material, and tips on planning, design, and architecture round out The Book of Visual Basic 2005. Professional developers who need to master VB 2005 will want this book by their side. About the author Matthew MacDonald is a developer, author, and educator dedicated to all things Visual Basic and .NET. He’s worked with Visual Basic and ASP since their initial versions, and he has written more than a dozen books, including The Book of VB .NET (No Starch Press) and Visual Basic 2005: A Developer’s Notebook (O’Reilly). YOUR PAS S PORT TO THE WORLD OF .NET YOUR PAS S PORT TO THE WORLD OF .NET www.nostarch.com “I lay flat.” This book uses RepKover —a durable binding that won’t snap shut. TH E FI N EST I N G E E K E N TE RT A I N M E NT ™ SHELVE IN: PROGRAMMING LANGUAGES/ VISUAL BASIC $39.95 ($51.95 CDN) M AC D O NA L D V I SUA L BA SIC 2005 V I SUA L BA SIC 2005 T H E B O O K of M a t t h e w M a c D o n a l d V ISUA L BA SIC 2005 V ISUA L BA SIC 2005 . N E T I N S I G H T F O R C L A S S I C V B D E V E L O P E R S bvb_02.book Page ii Thursday, March 30, 2006 12:39 PM THE BOOK OFVISUAL BASIC 2005 .NET Insight for Classic VB Developers by Matthew MacDonald San Francisco bvb_02.book Page iii Thursday, March 30, 2006 12:39 PM THE BOOK OF VISUAL BASIC 2005. Copyright © 2006 by Matthew MacDonald. 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. Printed on recycled paper in the United States of America 1 2 3 4 5 6 7 8 9 10 – 09 08 07 06 No Starch Press and the No Starch Press logo are registered trademarks of No Starch Press, Inc. Other product and company names mentioned herein may be the trademarks of their respective owners. Rather than use a trademark symbol with every occurrence of a trademarked name, we are using the names only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. Publisher: William Pollock Managing Editor: Elizabeth Campbell Associate Production Editor: Christina Samuell Cover and Interior Design: Octopod Studios Developmental Editor: Jim Compton Technical Reviewer: Dan Mabbutt Copyeditor: Neil Ching Compositor: Riley Hoffman Proofreader: Stephanie Provines For information on book distributors or translations, please contact No Starch Press, Inc. directly: No Starch Press, Inc. 555 De Haro Street, Suite 250, San Francisco, CA 94107 phone: 415.863.9900; fax: 415.863.9950; info@nostarch.com; www.nostarch.com The information in this book is distributed on an “As Is” basis, without warranty. While every precaution has been taken in the preparation of this work, neither the author nor No Starch Press, Inc. 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 it. Library of Congress Cataloging-in-Publication Data MacDonald, Matthew. The Book of Visual Basic 2005 : .NET Insight for Classic VB Developers / Matthew MacDonald. p. cm. Includes index. ISBN 1-59327-074-7 1. Microsoft Visual BASIC. 2. BASIC (Computer program language) 3. Microsoft .NET Framework. I. Title. QA76.73.B3M282 2005 005.2'768 dc22 2005028823 bvb_02.book Page iv Thursday, March 30, 2006 12:39 PM For Faria bvb_02.book Page v Thursday, March 30, 2006 12:39 PM ACKNOWLEDGMENTS The collection of .NET titles on bookstore shelves is embarrassingly large. When writing a book about a language as popular as Visual Basic, the challenge isn’t finishing it, but making sure that it’s really insightful, friendly, and useful beyond the standard Microsoft documentation. To that end, I have to thank countless other developers and .NET aficionados whose words—in books, articles, websites, discussions groups, and emails—have provided the seeds of insight that have enhanced the pages of this book. I hope the readers of this book will also learn from and become a part of the broader .NET community. Closer to home, I should thank all the pleasant people at No Starch Press who have worked with me throughout this project, for both this edition and the previous one, including Bill Pollock, Karol Jurado, Christina Samuell, Elizabeth Campbell, and Amanda Staab. I also owe a heartfelt thanks to this book’s reviewers, Dan Mabbutt of About.com fame and Jim Compton, and its copyeditor, Neil Ching. Lastly, I need to thank my parents (all four of them) and my loving wife. bvb_02.book Page vi Thursday, March 30, 2006 12:39 PM BRIEF CONTENTS Introduction 1 Chapter 1: The .NET Revolution 7 Chapter 2: The Design Environment 19 Chapter 3: VB 2005 Basics 47 Chapter 4: Windows Forms 87 Chapter 5: Object-Oriented Programming 135 Chapter 6: Mastering Objects 173 Chapter 7: Assemblies and Components 211 Chapter 8: Bug Proofing 239 Chapter 9: Dealing with Data: Files, Printing, and XML 271 Chapter 10: Databases and ADO.NET 311 Chapter 11: Threading 355 Chapter 12: Web Forms and ASP.NET 387 Chapter 13: Web Services 425 Chapter 14: Setup and Deployment 451 Index 475 bvb_02.book Page vii Thursday, March 30, 2006 12:39 PM bvb_02.book Page viii Thursday, March 30, 2006 12:39 PM CONTENTS IN DETAIL INTRODUCTION 1 Who Should Read This Book 2 What You Will Learn 2 Code Samples 3 Complaints, Adulation, and Everything in Between 3 Chapter Overview 4 What Comes Next? 5 1 THE .NET REVOLUTION 7 A Brief History of Visual Basic 7 Enter .NET 8 The Limitations of “Classic” Visual Basic 8 Visual Basic’s Quirky Mix 8 Isolated Languages 9 Enterprise Development Headaches 9 DLL Hell 9 Incomplete Support for Object-Oriented Programming 10 The .NET Vision 10 The Ingredients of .NET 10 The Common Language Runtime (CLR) 11 The .NET Classes 11 Speaking the Same Language 12 Deep Language Integration 13 Prebuilt Infrastructure 13 Web Services and the Next-Generation Internet 14 Open Standards: XML, SOAP, WSDL, and Other Letters from the Alphabet 14 Metadata: The End of DLL Hell? 15 Is VB 2005 Still VB? 15 Ten Enhancements You Can’t Live Without 16 Ten Changes That May Frustrate You 16 The Dark Side of .NET 17 What About COM? 17 What Comes Next? 18 2 THE DESIGN ENVIRONMENT 19 New in .NET 20 Starting Out in the IDE 21 The Start Page 22 Changing the Startup Behavior 23 bvb_02.book Page ix Thursday, March 30, 2006 12:39 PM x Contents in Detail Creating a Project 24 Tabbed Documents 25 Docked and Grouped Windows 26 Touring Visual Studio 27 The Solution Explorer 27 The Toolbox 28 The Properties Window 30 The Code Display 31 Splitting Windows 32 The Task List 34 Code Snippets 35 Inserting a Snippet 35 Managing Snippets 36 Macros 37 The Macro IDE 38 The Temporary Macro 39 Macros with Intelligence 39 Macros and Events 40 The Simplest Possible .NET Program 41 MyFirstConsoleApplication Files 43 MyFirstConsoleApplication Directories 43 Project Properties 44 What Comes Next? 46 3 VB 2005 BASICS 47 New in .NET 48 Introducing the Class Library 49 Namespaces 49 Assemblies 51 Types 52 Using the Class Library 53 Adding a Reference to an Assembly 53 Importing a Namespace 55 Exploring the Class Library Namespaces 57 The My Object 60 Code Files 62 Class and Module Blocks 63 Namespace Blocks 64 Adding Code Files 64 Data Types 65 The System Types 65 Multiple Variable Declaration 66 Initializers 66 Data Types as Objects 67 Strings 67 More Efficient Strings 70 Dates and Times 71 Arrays 71 Arrays and IEnumerable 72 bvb_02.book Page x Thursday, March 30, 2006 12:39 PM [...]... And there was no way to drop projects from earlier versions of Visual Basic into the new VB NET world So how does Visual Basic 2005 fit into this evolution? Visual Basic 2005 is VB NET 2.0 Microsoft marketers decided that the NET moniker was confusing the heck out of pretty much everyone, so they dropped it However, they didn’t change the language to make it one iota closer to classic VB In fact, Visual. .. Now Microsoft has introduced Visual Basic 2005, along with the second version of the NET Framework Microsoft’s developers have expended considerable resources making Visual Basic 2005 easier to understand, use, and embrace, and they’re earmarking this release as the version that will finally make die-hard classic VB- ers switch to NET So have they succeeded? As you’ll discover in this book, there’s still... NET Forms 104 Two Ways to Show a Form 104 Forms and the My Object 106 Modal Forms 107 The Startup Form and Shutdown Mode 108 Application Events 108 Form Oddities 110 The Inner Workings of Forms 111 Visual Basic 6 Forms “Under the Hood” 112 Visual Basic 2005 Forms “Under the Hood” 113 Stepping Through the. .. step up from classic VB, and it’s claiming it works a lot more like classic VB does In a few superficial cases, this is true (as with the return of edit-and-continue) But overall, it’s no easier to move to Visual Basic 2005 than it was to move to VB NET 1.0 The Limitations of Classic Visual Basic Have you heard the argument, “Before you can understand the solution, you have to understand the problem”?... waiting for This book provides a guided tour through the world of Visual Basic 2005 In it, you’ll learn how you can use your existing VB skills and master the NET way of thinking Who Should Read This Book This book is aimed at Visual Basic 6 developers who want to shed some of their current habits and start learning about how the NET platform works and thinks We won’t spend any time rehashing basic syntax,... did more to crush the personal self-esteem of the dedicated VB programmer The NET Vision Most people were expecting Microsoft to deal with some of these complaints by bolting on a few new features, as it did for the previous few versions of Visual Basic As advanced developers started to expand the types of programs that Visual Basic was used to develop, cracks in the VB picture started to appear— everywhere... migration path— Visual Basic 2005 is entirely unlike Visual Basic 6, and there’s no turning back now However, if you’re ready to step up to a new language—one that cleans out old cobwebs, levels the playing field between VB and other programming languages, and introduces an avalanche of elegant, flexible, and easy-to-use new features Visual Basic 2005 fits the bill In fact, it’s the Visual Basic makeover... support for resizable forms, a variety of new controls, and the ability to finally forget all about the Windows API Chapter 5: Object-Oriented Programming At last, Visual Basic 2005 is a full object-oriented programming language This chapter teaches you the basics of object-oriented development, the most modern and elegant way to solve almost any programming problem VB 2005 is built almost entirely out of. .. before we go any further, let’s take a look at some of Visual Basic s most infamous shortcomings that VB. NET was designed to address Visual Basic s Quirky Mix Visual Basic s evolution has been so quick that the last version (6.0) was a mixture of cutting-edge features and Paleolithic throwbacks For example, Visual Basic 6 provided a great framework for creating a graphical user 8 C h a pt er 1 bvb_02 .book. .. application: the streamlined web-based ClickOnce model, and the more comprehensive Visual Studio setup project What Comes Next? If you’ve made it this far, I’ll assume you’re continuing for the rest of the journey For best results, you should already have a copy of Visual Basic 2005 The professional edition is best (it includes support for every type of project), but you can also complete many of the examples . indirectly by the information contained in it. Library of Congress Cataloging-in-Publication Data MacDonald, Matthew. The Book of Visual Basic 2005 : .NET Insight for Classic VB Developers / Matthew. O P E R S bvb_02 .book Page ii Thursday, March 30, 2006 12:39 PM THE BOOK OF ™ VISUAL BASIC 2005 .NET Insight for Classic VB Developers by Matthew MacDonald San Francisco bvb_02 .book Page iii. and architecture round out The Book of Visual Basic 2005. Professional developers who need to master VB 2005 will want this book by their side. About the author Matthew MacDonald is a developer,

Ngày đăng: 17/04/2014, 09:17

Từ khóa liên quan

Mục lục

  • THE BOOK OF VISUAL BASIC 2005

    • Content

    • Introduction

    • Chapter 1: The .NET Revolution

    • Chapter 2: The Design Environment

    • Chapter 3: VB 2005 Basics

    • Chapter 4: Windows Forms

    • Chapter 5: Object-Oriented Programming

    • Chapter 6: Mastering Objects

    • Chapter 7: Assemblies and Components

    • Chapter 8: Bug Proofing

    • Chapter 9: Dealing with Data: Files, Printing, and XML

    • Chapter 10: Databases and ADO.NET

    • Chapter 11: Threading

    • Chapter 12: Web Forms and ASP.NET

    • Chapter 13: Web Services

    • Chapter 14: Setup and Deployment

    • Index

Tài liệu cùng người dùng

Tài liệu liên quan