Programming Microsoft Visual Basic NET Version 2003 Francesco Balena instant download
Programming Microsoft Visual Basic NET Version 2003 Francesco Balena instant download
https://ebookultra.com/download/programming-microsoft-visual-
basic-net-version-2003-francesco-balena/
https://ebookultra.com/download/programming-microsoft-sql-
server-2000-with-microsoft-visual-basic-net-1st-edition-edition-rick-
dobson/
https://ebookultra.com/download/sams-teach-yourself-microsoft-visual-
basic-net-2003-in-21-days-2nd-edition-steven-holzner/
https://ebookultra.com/download/sams-teach-yourself-microsoft-visual-
basic-net-2003-in-24-hours-complete-starter-kit-2nd-edition-james-
foxall/
https://ebookultra.com/download/programming-with-microsoft-visual-
basic-2012-6th-edition-diane-zak/
Programming the Web with Visual Basic NET 1st Edition Lynn
Torkelson
https://ebookultra.com/download/programming-the-web-with-visual-basic-
net-1st-edition-lynn-torkelson/
https://ebookultra.com/download/practical-database-programming-with-
visual-basic-net-second-edition-ying-baiauth/
https://ebookultra.com/download/an-introduction-to-object-oriented-
programming-with-visual-basic-net-1st-edition-dan-clark/
https://ebookultra.com/download/mastering-microsoft-visual-
basic-2008-evangelos-petroutsos/
https://ebookultra.com/download/microsoft-visual-basic-programs-to-
accompany-programming-logic-and-design-3rd-edition-jo-ann-smith/
Programming Microsoft Visual Basic NET Version 2003
Francesco Balena Digital Instant Download
Author(s): Francesco Balena
ISBN(s): 9780735620599, 0735620598
Edition: Hardcover/CD-ROM combo
File Details: PDF, 10.99 MB
Year: 2004
Language: english
PUBLISHED BY
Microsoft Press
A Division of Microsoft Corporation
One Microsoft Way
Redmond, Washington 98052-6399
Copyright © 2004 by Francesco Balena
All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by
any means without the written permission of the publisher.
Library of Congress Cataloging-in-Publication Data
Balena, Francesco, 1960-
Programming Microsoft Visual Basic .NET version 2003 / Francesco Balena.
p. cm.
Includes index.
ISBN 0-7356-2059-8
1. Microsoft Visual BASIC. 2. BASIC (Computer program lanuage) 3. Microsoft
.NET. I. Title.
QA76.73.B3B348 2003
005.2'768--dc22 2003058666
Printed and bound in the United States of America.
1 2 3 4 5 6 7 8 9 QWT 8 7 6 5 4 3
Distributed in Canada by H.B. Fenn and Company Ltd.
A CIP catalogue record for this book is available from the British Library.
Microsoft Press books are available through booksellers and distributors worldwide. For further information
about international editions, contact your local Microsoft Corporation office or contact Microsoft Press
International directly at fax (425) 936-7329. Visit our Web site at www.microsoft.com/mspress. Send comments
to mspinput@microsoft.com.
Active Directory, ActiveX, Authenticode, ClearType, DirectX, IntelliMouse, IntelliSense, JScript,
Microsoft, Microsoft Press, MS-DOS, MSDN, Outlook, PowerPoint, Visual Basic, Visual C++, Visual
C#, Visual J#, Visual Studio, Win32, Windows, and Windows NT are either registered trademarks or
trademarks of Microsoft Corporation in the United States and/or other countries. Other product and
company names mentioned herein may be the trademarks of their respective owners.
The example companies, organizations, products, domain names, e-mail addresses, logos, people, places,
and events depicted herein are fictitious. No association with any real company, organization, product,
domain name, e-mail address, logo, person, place, or event is intended or should be inferred.
This book expresses the author’s views and opinions. The information contained in this book is provided
without any express, statutory, or implied warranties. Neither the authors, Microsoft Corporation, nor its
resellers or distributors will be held liable for any damages caused or alleged to be caused either directly
or indirectly by this book.
Acquisitions Editor: Danielle Bird Voeller
Project Editor: Kathleen Atkins
Technical Editor: Jeff Webb
Indexer: Virginia Bess
Body Part No. X10-21789
To Adriana, the love of my life
Contents
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xxiii
Foreword. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxv
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii
v
vi Contents
5 Inheritance 129
Inheritance Basics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Extending the Derived Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Using the Derived Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Polymorphic Behavior. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Overriding Members in the Base Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Override Variations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
The MyBase Keyword. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
Constructors in Derived Classes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
The MyClass Keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Member Shadowing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Redefining Shared Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
Sealed and Virtual Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
The NotInheritable Keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
The MustInherit Keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
The MustOverride Keyword. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Nested Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Public, Private, and Friend Scope Qualifiers . . . . . . . . . . . . . . . . . . . . . . . . 149
The Protected Scope Qualifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
The Protected Friend Scope Qualifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Using Scope Qualifiers with Constructors . . . . . . . . . . . . . . . . . . . . . . . . . 151
Redefining Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Object Lifetime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
COM and the Reference Counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Garbage Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
The Finalize Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
The Dispose Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Weak Object References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
Delegates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Invoking Static Methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Invoking Instance Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Other Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Callback Procedures and Code Reuse. . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Multicast Delegates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Delegates and Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Attribute Syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
The Conditional Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
The Obsolete Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
The DebuggerStepThrough Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
Enums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
Displaying and Parsing Enum Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Other Enum Methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Bit-Coded Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
12 Threading 326
Threading Fundamentals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326
When to Use Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 326
Creating Threads. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
Working with Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328
Thread Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
Debugging Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332
Threads and Unhandled Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334
Storing and Sharing Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 336
Local, Class, and Static Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
The ThreadStatic Attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
Passing Data to and from a Thread. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
Thread Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
The SyncLock Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
Synchronized Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 342
The Monitor Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344
The Interlocked Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
The Mutex Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 346
The ReaderWriterLock Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 348
The ManualResetEvent and AutoResetEvent Classes . . . . . . . . . . . . . . . . . 350
Using the Thread Pool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
The ThreadPool Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Contents xi
14 Reflection 390
Working with Assemblies and Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
The Assembly Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
The AssemblyName Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
The Module Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
Working with Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
Getting a Type Object. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
Retrieving Type Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
Enumerating Members. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
Retrieving Member Information. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
Enumerating Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
Invoking Members . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
Creating an Object Dynamically . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
Dynamic Registration of Event Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . 406
xii Contents
17 GDI+ 551
2-D Vector Graphics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 551
The Graphics Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 552
Lines, Rectangles, Polygons, Ellipses, and Arcs. . . . . . . . . . . . . . . . . . . . . 553
Cardinal and Bézier Splines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
The Pen Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556
Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 558
Filled Shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559
Brush Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560
Regions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 564
Alpha Blending . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566
Transformations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567
Imaging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570
Loading and Saving Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570
Displaying an Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
Flipping, Rotating, and Skewing an Image . . . . . . . . . . . . . . . . . . . . . . . . . 573
Transparent and Semitransparent Bitmaps . . . . . . . . . . . . . . . . . . . . . . . . 577
Icons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578
Metafiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 579
Typography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 580
Font Families . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
Drawing Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 582
Aligned Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584
Textual Variations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 585
Anti-Aliasing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586
xiv Contents
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookultra.com