Visual Basic 2012 Unleashed
Alessandro Del Sole
800 East 96th Street, Indianapolis, Indiana 46240 USA
Visual Basic 2012 Unleashed
Copyright 2013 by Pearson Education, Inc.
All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the information contained herein.
ISBN-10: 0-672-33631-6
ISBN-13: 978-0-672-33631-7
Library of Congress Cataloging-in-Publication Data is on file.
Printed in the United States of America
First Printing: January 2013
Editor-in-Chief
Greg Wiegand
Executive Editor
Neil Rowe
Acquisitions Editor
Brook Farling
Development Editor
Mark Renfrow
Managing Editor
Kristy Hart
Project Editor
Anne Goebel
Copy Editor
Megan Wade
Indexer
WordWise Publishing Services
Proofreader
Debbie Williams
Technical Editor
Matt Kleinwaks
Publishing Coordinator
Cindy Teeters
Cover Designer
Anne Jones
Compositor
Nonie Ratcliff
Trademarks
All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Pearson Education, Inc. cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark.
Warning and Disclaimer
Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an as is basis. The author and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book.
Bulk Sales
Pearson offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales. For more information, please contact:
U.S. Corporate and Government Sales
1-800-382-3419
For sales outside of the U.S., please contact:
International Sales
+1-317-581-3793
Contents at a Glance
Table of Contents
Foreword
From his blog posts (in Italian and English) to his forum answers, from his online articles to his code snippets, from his technical speeches and user-groups to his books, the breadth of Alessandros reach has been astounding.
Now is a particularly good time for Alessandro to write this book, because the current release of Visual Basic has so many new features. Id like to tell the story behind the most important of them, . We introduced this feature because everyone wants their interactive applications to be fast and responsive, but the code to achieve this has traditionally been too convoluted. Now, thanks to asynchronous programming, the code has become straightforward. Although the code itself is straightforward, our small design group at Microsoft knew we were producing something unfamiliar as we sat down to design the feature in early 2010something not taught in college courses, something whose success would depend on the ability of authors like Alessandro to explain it (which he does well).
As Language Designer of VB, I implemented the initial prototype of the feature within the VB and C# compilers. Our team first revealed it behind closed doors to MVPs (Most Valued Professionals) such as Alessandro at a small gathering in New Orleans, hoping that the attendees would see its worth but daunted by the challenge of explaining something so unusual. The MVPs understood the features potential. They also asked us to integrate it better with other parts of Visual Studio such as debugging (), which we then did.
Indeed, there are manual useful parts to Visual Studio and .NET, and Alessandro knows them all. In this book, he makes sure that you will know all the important ones, too, and he sets them in context by explaining when and why to use them. I myself was happy to learn how to do localization () from this bookboth topics that I was aware of but hadnt explored before.
Alessandro has found just the right blend of text, code, and screenshots to explain Visual Studio effectively. Beginners and experts alike will find much of value in this book.
Lucian Wischik
Seattle, Washington
December 2012
About the Author
Alessandro Del Sole, a Microsoft Most Valuable Professional (MVP) for Visual Basic since 2008, is well known throughout the global VB community. He is a community leader on the Italian Visual Basic Tips and Tricks website (http://www.visual-basic.it) that serves more than 42,000 VB developers, as well as a frequent contributor to the MSDN Visual Basic Developer Center. He enjoys writing articles on .NET development, writing blog posts on both his Italian and English blogs, and producing instructional videos as well as apps for Windows 8 and Windows Phone. You can find him online in forums or newsgroups. Alessandro has been awarded MVP of the Year for Visual Basic in 2009, 2010, and 2011.
Dedication
To my parents, Im learning from you how one should never give up even when life becomes the hardest possible. As usual, you taught me the most important lessons in life. The more time goes on, the more I understand what you have done for me. Thank you!
To my best friend Nadia, who always finds a way to make me smile when things become so difficult and is always able to find positive perspectives when I cannot. You have really been one of the most important people in my whole life for more than 10 years, and I will always be there for you.
Acknowledgments
First of all, I would like to thank Neil Rowe, Mark Renfrow, Anne Goebel, and all at Sams Publishing for trusting me enough to write the second edition of this book about Visual Basic. Writing books like this is hard work, not only for the author, but also for all the people involved in the reviews and in the production process. Working with these guys made the process much more pleasant. Thank you!
Very special thanks to Matthew Kleinwaks, who has been the technical editor for this book and who is a Microsoft Visual Basic MVP. Matthew did an incredible job, walking through every single word and line of code, engaging interesting technical discussions. His suggestions have been so important and made the content as accurate and interesting as possible. You can visit Matthews blog at http://zerosandtheone.com/. Thank you so much, Matt!
Special thanks to all the Microsoft Visual Basic Team for doing a great job; particularly I would like to give my special thanks to Lucian Wischik, Lisa Feigenbaum, Beth Massi, and Anthony D. Green for providing opportunities of continuous interactions and technical discussions. They contribute and keep the passion for Visual Basic alive around the globe.
Great thanks also to the guys from the Italian subsidiary of Microsoft: Alessandro Teglia (my MVP lead), who has a great passion for his work and for the MVP community; he did a really great job when I had some important questions related to information required for this book, quickly pointing me in the right direction. Also, special thanks to the local Development and Platform Evangelism Division (Marco Agnoli, Francesca Longoni, Francesca Marinoni, Lorenzo Barbieri, Vito Lorusso, Pietro Brambati, Mario Fontana, Gabriele Castellani, and Irina Turcu) for their continuous support and encouragement for my activities.