ebook img

Visual basic 2012 : programmer's reference PDF

844 Pages·2012·23.773 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 Visual basic 2012 : programmer's reference

ffffiirrss..iinndddd ii 1199//0077//1122 22::0033 PPMM VISUAL BASIC® 2012 PROGRAMMER’S REFERENCE INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii (cid:2) 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 (cid:2) 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 ffffiirrss..iinndddd ii 1199//0077//1122 22::0033 PPMM (cid:2) 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 G enerics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515 (cid:2) 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 (cid:2) 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 ffffiirrss..iinndddd iiii 1199//0077//1122 22::0033 PPMM 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 ffffiirrss..iinndddd iiiiii 1199//0077//1122 22::0033 PPMM ffffiirrss..iinndddd iivv 1199//0077//1122 22::0033 PPMM Visual Basic® 2012 PROGRAMMER’S REFERENCE Rod Stephens John Wiley & Sons, Inc. ffffiirrss..iinndddd vv 1199//0077//1122 22::0033 PPMM 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 specifi cally disclaim all warranties, including without limitation warranties of fi 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 affi 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. ffffiirrss..iinndddd vvii 1199//0077//1122 22::0033 PPMM 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 fi 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 [email protected] or [email protected]. 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. ffffiirrss..iinndddd vviiii 1199//0077//1122 22::0033 PPMM CREDITS Executive Editor Production Manager Robert Elliott Tim Tate Senior Project Editor Vice President and Executive Group Adaobi Obi Tulton Publisher Richard Swadley Technical Editor Brian Hochgurtel Vice President and Executive Publisher Neil Edde Production Editor Daniel Scribner Associate Publisher Jim Minatel Copy Editor Kim Cofer Project Coordinator, Cover Katie Crocker Editorial Manager Mary Beth Wakefi eld Proofreader Nicole Hirschman Freelancer Editorial Manager Rosemarie Graham Indexer Ron Strauss Associate Director of Marketing David Mayhew Cover Designer Ryan Sneed Marketing Manager Ashley Zurcher Cover Image © Erik Isakson / Tetra Images / JupiterImages Business Manager Amy Knies ffffiirrss..iinndddd vviiiiii 1199//0077//1122 22::0033 PPMM

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.