visual basic 2012 programmers reference

844 2.7K 0
visual basic 2012 programmers reference

Đ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

www.it-ebooks.info ffirs.indd iffirs.indd i 19/07/12 2:03 PM19/07/12 2:03 PM www.it-ebooks.info VISUAL BASIC® 2012 PROGRAMMER’S REFERENCE INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii  PART I IDE CHAPTER 1 Introduction to the IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 CHAPTER 2 Menus, Toolbars, and Windows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15 CHAPTER 3 Windows Forms Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 CHAPTER 4 WPF Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 CHAPTER 5 Visual Basic Code Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 CHAPTER 6 Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69  PART II GETTING STARTED CHAPTER 7 Selecting Windows Forms Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81 CHAPTER 8 Using Windows Forms Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 CHAPTER 9 Windows Forms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115 CHAPTER 10 Selecting WPF Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 CHAPTER 11 Using WPF Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 CHAPTER 12 WPF Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 CHAPTER 13 Program and Module Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 CHAPTER 14 Data Types, Variables, and Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 CHAPTER 15 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 CHAPTER 16 Subroutines and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 CHAPTER 17 Program Control Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 CHAPTER 18 Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 CHAPTER 19 Database Controls and Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 CHAPTER 20 LINQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381 CHAPTER 21 Metro-Style Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .417 ffirs.indd iffirs.indd i 19/07/12 2:03 PM19/07/12 2:03 PM www.it-ebooks.info  PART III OBJECTORIENTED PROGRAMMING CHAPTER 22 OOP Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433 CHAPTER 23 Classes and Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449 CHAPTER 24 Namespaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481 CHAPTER 25 Collection Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493 CHAPTER 26 Generics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515  PART IV INTERACTING WITH THE ENVIRONMENT CHAPTER 27 Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529 CHAPTER 28 Confi guration and Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547 CHAPTER 29 Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571 CHAPTER 30 Filesystem Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585  PART V APPENDICES APPENDIX A Useful Control Properties, Methods, and Events . . . . . . . . . . . . . . . . . . . 611 APPENDIX B Variable Declarations and Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . 619 APPENDIX C Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 629 APPENDIX D Subroutine and Function Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . 637 APPENDIX E Control Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641 APPENDIX F Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647 APPENDIX G Windows Forms Controls and Components . . . . . . . . . . . . . . . . . . . . . . 649 APPENDIX H WPF Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657 APPENDIX I Visual Basic Power Packs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 665 APPENDIX J Form Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669 APPENDIX K Classes and Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 681 APPENDIX L LINQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 685 APPENDIX M Generics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 695 APPENDIX N Graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699 APPENDIX O Useful Exception Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 711 APPENDIX P Date and Time Format Specifi ers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715 ffirs.indd iiffirs.indd ii 19/07/12 2:03 PM19/07/12 2:03 PM www.it-ebooks.info APPENDIX Q Other Format Specifi ers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 719 APPENDIX R The Application Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 725 APPENDIX S The My Namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 729 APPENDIX T Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 747 APPENDIX U Filesystem Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 755 APPENDIX V Visual Studio Versions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .771 INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 773 ffirs.indd iiiffirs.indd iii 19/07/12 2:03 PM19/07/12 2:03 PM www.it-ebooks.info ffirs.indd ivffirs.indd iv 19/07/12 2:03 PM19/07/12 2:03 PM www.it-ebooks.info Visual Basic ® 2012 PROGRAMMER’S REFERENCE Rod Stephens John Wiley & Sons, Inc. ffirs.indd vffirs.indd v 19/07/12 2:03 PM19/07/12 2:03 PM www.it-ebooks.info Visual Basic® 2012 Programmer’s Reference Published by John Wiley & Sons, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2012 by John Wiley & Sons, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-1-118-31407-4 ISBN: 978-1-118-33208-5 (ebk) ISBN: 978-1-118-33535-2 (ebk) ISBN: 978-1-118-43938-8 (ebk) Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 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 Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions. 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 speci cally disclaim all warranties, including without limitation warranties of  tness for a particular purpose. No warranty may be created or extended by sales or pro- motional 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 pub- lisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site 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 Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web sites 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 United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002. Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with stan- dard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media such as a CD or DVD that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com. Library of Congress Control Number: 2012940034 Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its af liates, in the United States and other coun- tries, and may not be used without written permission. Visual Basic is a registered trademark of Microsoft Corporation. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc., is not associated with any product or vendor mentioned in this book. ffirs.indd viffirs.indd vi 19/07/12 2:03 PM19/07/12 2:03 PM www.it-ebooks.info ABOUT THE AUTHOR ROD STEPHENS started out as a mathematician, but while studying at MIT, he discovered how much fun programming is and has been programming profes- sionally ever since. During his career, he has worked on an eclectic assortment of applications in such  elds as telephone switching, billing, repair dispatching, tax processing, wastewater treatment, concert ticket sales, cartography, and training for professional football players. Rod is a Microsoft Visual Basic Most Valuable Professional (MVP) and has taught introductory programming at ITT Technical Institute. He has written more than two dozen books that have been translated into languages from all over the world, and more than 250 magazine articles covering Visual Basic, C#, Visual Basic for Applications, Delphi, and Java. Rod’s popular VB Helper website ( www.vb-helper.com) receives several million hits per month and contains thousands of pages of tips, tricks, and example programs for Visual Basic programmers, as well as example code for this book. His C# Helper website ( www.csharphelper.com) contains similar material for C# programmers. You can contact Rod at RodStephens@csharphelper.com or RodStephens@vb-helper.com. ABOUT THE TECHNICAL EDITOR BRIAN HOCHGURTEL has been doing .NET development for over ten years, and actually started his .NET experience with Rod Stephens when they wrote the Wiley book Visual Basic .NET and XML together in 2002. Currently Brian works as a SharePoint Developer and Administrator for a large defense contractor in Colorado. ffirs.indd viiffirs.indd vii 19/07/12 2:03 PM19/07/12 2:03 PM www.it-ebooks.info Executive Editor Robert Elliott Senior Project Editor Adaobi Obi Tulton Technical Editor Brian Hochgurtel Production Editor Daniel Scribner Copy Editor Kim Cofer Editorial Manager Mary Beth Wakefi eld Freelancer Editorial Manager Rosemarie Graham Associate Director of Marketing David Mayhew Marketing Manager Ashley Zurcher Business Manager Amy Knies Production Manager Tim Tate Vice President and Executive Group Publisher Richard Swadley Vice President and Executive Publisher Neil Edde Associate Publisher Jim Minatel Project Coordinator, Cover Katie Crocker Proofreader Nicole Hirschman Indexer Ron Strauss Cover Designer Ryan Sneed Cover Image © Erik Isakson / Tetra Images / JupiterImages CREDITS ffirs.indd viiiffirs.indd viii 19/07/12 2:03 PM19/07/12 2:03 PM www.it-ebooks.info [...]... LANGUAGES Visual Studio also supports a few other languages including Visual C++, Visual J#, and Visual F#, and in theory it could support others in the future Visual Studio was originally built for Visual Basic and C# so it provides the most support for these A Visual Basic programmer’s joke asks, “What’s the difference between Visual Basic NET and C#? About three months!” The implication is that Visual Basic. .. difficult branches of science If you ever used Visual Basic 3, you too could have known everything Visual Basic 3 was a reasonably small but powerful language Visual Basic 4 added classes to the language and made Visual Basic much more complicated Versions 4, 5, and 6 added more support for database programming and other topics such as custom controls, but Visual Basic was still a fairly understandable language,... programming language If you know Visual Basic, you have a big head start in using these other languages ASP and VBA are based on pre-.NET versions of Visual Basic, so you won’t instantly know how to use them, but you’ll have an advantage if you need to learn ASP or VBA If you are new to programming, either Visual Basic 2012 or C# is a good choice I think Visual Basic 2012 is a little easier to learn,... controls and components provided by Visual Basic 2012 Appendix H, “WPF Controls,” summarizes the most useful WPF controls Appendix I, Visual Basic Power Packs,” lists some additional tools that you can download to make Visual Basic development easier Appendix J, “Form Objects,” describes forms Forms are just another type of control but they play such a key role in Visual Basic applications that they deserve... Java, you will probably fi nd C# (or Visual C++ or Visual J#) easy to learn Visual Basic does have some ties with other Microsoft products that increase its value For example, Active Server Pages (ASP) and ASP.NET use Visual Basic to create interactive web pages Microsoft Office applications (Word, Excel, PowerPoint, and so forth) and many third-party tools use Visual Basic for Applications (VBA) as a... a broad, solid understanding of essential Visual Basic topics It explains the powerful development environment that makes Visual Basic such a productive language It describes the Visual Basic language itself and explains how to use it to perform a host of important development tasks It also explains the forms, windows, controls, and other objects that Visual Basic provides for building applications... building applications with it is faster Similarly, C# programmers have their jokes about Visual Basic NET, implying that C# is more powerful In fact, Visual Basic NET is not a whole lot easier to use than C#, and C# is not significantly more powerful The basic form of the two languages is very similar Aside from a few stylistic differences (Visual Basic is line-oriented; C# uses lots of braces and semicolons),... languages are comparable Both use the Visual Studio development environment, both provide access to the NET Framework of support classes and tools, and both provide similar syntax for performing basic programming tasks The main difference between these languages is one of style If you have experience with previous versions of Visual Basic, you will probably fi nd Visual Basic 2012 easier to get used to If... applications easier Visual Studio is so powerful that the answer to the question of whether you should use it is practically obvious: If you want to write powerful applications that run in a Windows operating system, you should use Visual Studio Visual Basic is not the only language that uses Visual Studio The C# language does, too, so now the question is, should you use Visual Basic or C#? xxviii... little easier to learn, but I may be slightly biased because I’ve been using Visual Basic since long before C# was invented You won’t be making a big mistake either way, and you can easily switch later, if necessary WHO SHOULD READ THIS BOOK This book is intended for programmers of all levels It describes the Visual Basic 2012 language from scratch, so you don’t need experience with previous versions . PM www.it-ebooks.info Visual Basic ® 2012 PROGRAMMER’S REFERENCE Rod Stephens John Wiley & Sons, Inc. ffirs.indd vffirs.indd v 19/07/12 2:03 PM19/07/12 2:03 PM www.it-ebooks.info Visual Basic 2012 Programmer’s. www.it-ebooks.info ffirs.indd iffirs.indd i 19/07/12 2:03 PM19/07/12 2:03 PM www.it-ebooks.info VISUAL BASIC 2012 PROGRAMMER’S REFERENCE INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . into languages from all over the world, and more than 250 magazine articles covering Visual Basic, C#, Visual Basic for Applications, Delphi, and Java. Rod’s popular VB Helper website ( www.vb-helper.com)

Ngày đăng: 05/05/2014, 12:40

Từ khóa liên quan

Mục lục

  • Visual Basic® 2012: Programmer's Reference

  • About the Author

  • About the Technical Editor

  • Credits

  • Acknowledgments

  • Contents

  • Introduction

    • Should you use visual basic 2012?

    • Who Should Read this Book

    • How this Book is Organized

      • Part I: IDE

      • Part II: Getting Started

      • Part III: Object-Oriented Programming

      • Part IV: Interacting with the Environment

      • Part V: Appendices

      • How to use this Book

      • Necessary Equipment

      • Conventions

      • Source Code

      • Errata

      • P2P.Wrox.Com

      • Important Urls

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

Tài liệu liên quan