Visual Basic NET Codemaster s Library Matt Tagliaferri 2024 Scribd Download
Visual Basic NET Codemaster s Library Matt Tagliaferri 2024 Scribd Download
https://ebookgate.com
https://ebookgate.com/product/visual-basic-net-
codemaster-s-library-matt-tagliaferri/
https://ebookgate.com/product/visual-basic-net-a-beginner-s-guide-
jeff-kent/
ebookgate.com
https://ebookgate.com/product/programming-visual-basic-net-1st-ed-
edition-dave-grundgeiger/
ebookgate.com
https://ebookgate.com/product/beginning-visual-basic-net-
databases-1st-edition-denise-gosnell/
ebookgate.com
https://ebookgate.com/product/mastering-visual-basic-net-database-
programming-1st-edition-evangelos-petroutsos/
ebookgate.com
MCAD MCSD Self Paced Training Kit Implementing Security
for Applications with Microsoft Visual Basic NET and
Microsoft C NET Anthony Northrup
https://ebookgate.com/product/mcad-mcsd-self-paced-training-kit-
implementing-security-for-applications-with-microsoft-visual-basic-
net-and-microsoft-c-net-anthony-northrup/
ebookgate.com
https://ebookgate.com/product/asp-net-site-performance-secrets-1st-
edition-matt-perdeck/
ebookgate.com
https://ebookgate.com/product/pro-visual-studio-net-1st-edition-bill-
sempf/
ebookgate.com
https://ebookgate.com/product/microsoft-visual-basic-game-programming-
for-teens-1st-edition-jonathan-s-harbour/
ebookgate.com
4103c00.qxd 2/14/02 9:12 PM Page iii
Copyright © 2002 SYBEX Inc., 1151 Marina Village Parkway, Alameda, CA 94501. World rights reserved. No part of this publication may
be stored in a retrieval system, transmitted, or reproduced in any way, including but not limited to photocopy, photograph, magnetic, or
other record, without the prior agreement and written permission of the publisher.
“.NET Delegates: A C# Bedtime Story” (in Part IX, “.NET Delegates: A C# (and now VB .NET) Bedtime Story”) Copyright © 1995-
2001, Chris Sells. All rights reserved. http://www.sellsbrothers.com
ISBN: 0-7821-4103-X
SYBEX and the SYBEX logo are either registered trademarks or trademarks of SYBEX Inc. in the United States and/or other countries.
Screen reproductions produced with FullShot 99. FullShot 99 © 1991-1999 Inbit Incorporated. All rights reserved.
FullShot is a trademark of Inbit Incorporated.
The screenshots from Microsoft® Word and Microsoft® Excel are copyright Microsoft Corporation. All rights reserved.
Internet screenshot(s) using Microsoft Internet Explorer 5 reprinted by permission from Microsoft Corporation.
TRADEMARKS: SYBEX has attempted throughout this book to distinguish proprietary trademarks from descriptive terms by following
the style used by the trademark holder wherever possible.
The author and publisher have made their best efforts to prepare this book, and the content is based upon final release software whenever
possible. Portions of the manuscript may be based upon pre-release versions supplied by software manufacturer(s). The author and the pub-
lisher make no representation or warranties of any kind with regard to the completeness or accuracy of the contents herein and accept no
liability of any kind including but not limited to performance, merchantability, fitness for any particular purpose, or any losses or damages
of any kind caused or alleged to be caused directly or indirectly from this book.
10 9 8 7 6 5 4 3 2 1
4103c00.qxd 2/14/02 9:12 PM Page v
Acknowledgments
his was a difficult book to write, and there were many people who made it possible. First,
T Tom Cirtin at Sybex receives thanks for shaping and focusing the idea of the book into its
final form. The next round of kudos goes to Kylie Johnston, Mae Lum, Sally Engelfried,
and Sarah Lemaire, who took my heap of manuscript and made a book out of it. I also need
to thank Greg Guntle and John Godfrey for going over the thousands of lines of code with a
fine-toothed comb and making sure it worked on more than the two PCs I have available
for .NET testing at the moment.
Finally, I need to thank my ever-tolerant wife Janet, who was forced to stare at my back as I
sat swearing in front of my PC these past few months.
4103c00.qxd 2/14/02 9:12 PM Page vii
Contents at a Glance
Introduction xvi
Index 365
4103c00.qxd 2/14/02 9:12 PM Page viii
Contents
Introduction xvi
Contents ix
11 Short Circuiting 35
The Potential Inefficiencies of VB 35
The Short Circuit 36
x Contents
Contents xi
xii Contents
Contents xiii
xiv Contents
Contents xv
Index 365
4103c00.qxd 2/14/02 9:12 PM Page xvi
Introduction
bout 18 months ago, I began reading about the forthcoming version of Visual Basic, and I
A was jazzed about it from the get-go. The early details were sketchy, but I did know that
Microsoft was going to turn Visual Basic into a full object-oriented language. I had experience
in some “full” object-oriented development and was quite impressed with the way that good
OOP design seemed to naturally organize my thoughts (and my code). I was eager to begin
using these design principles in Visual Basic.
Of course, such power was not to come without a price. The new Visual Basic, I would
learn, was not to be backward compatible with VB6. Since all of my current day job develop-
ment was in VB6, upgrading to the new language would not simply be a one-day slam-dunk,
as it was when I moved from Visual Basic 4 to 5 or from VB5 to VB6.
VB .NET in Perspective
Visual Basic .NET is, simply put, quite a large hunk of new functionality to learn for the
experienced Visual Basic developer. While Visual Studio .NET does ship with a VB6-to-
VB .NET project converter, you’ll quickly realize (maybe before even trying it out on one of
your projects) that a strict conversion is probably the wrong solution for all but the most triv-
ial of programs. The reason for this is that the VB .NET is much, much more than a list of
syntactical differences. .NET development presents radically new language features and ways
for programs to communicate with each other. For this reason, .NET applications will most
likely be designed differently from the ground up.
The first major difference that you’ll notice when perusing some VB .NET examples is the
true object-oriented nature of the language. Everything is a class in Visual Basic .NET. Your
application, the forms, all the buttons, labels, and Treeview objects are all instances of true
objects. This gives the language a previously unknown uniformity. It also gives you the power
to create descendant classes of common user interface classes should you need some enhanced
functionality and/or some additional data-storing properties.
The VB .NET object-oriented nature is closely coupled with the .NET Framework. The
.NET Framework is an object-oriented API of sorts. It represents hundreds of classes that
encapsulate functionality found in the Windows operating system or in resources like Mes-
sage Queue or SQL Server. These classes have been logically grouped into hierarchical orga-
nizational units called namespaces, which allow you to include only those namespaces in your
4103c00.qxd 2/14/02 9:12 PM Page xvii
Introduction xvii
program that you require. In truth, one cannot get very far learning about VB .NET without
also learning about the .NET Framework upon which the language is built.
One of the primary features of the .NET Framework that will radically change your pro-
gramming thought process is the concept of garbage collection. The .NET Framework man-
ages the memory of all objects automatically, which makes it nearly impossible to write a
program with old-style “memory leaks” caused by forgetting to free a resource. It also lets
you concentrate on the logic of your procedures instead of matching up every object instanti-
ation with a line of code that frees the object.
You’ll also greatly benefit from structured exception handling, a vast improvement over the
On Error Goto crud you’ve had to endure up to this point. An exception handler wraps a
block of code with one or more lines of code that can handle different types of errors. The
classes of exceptions range from very general to very specific, so you can handle a certain
class of errors one way (like writing a message to the event log) and another class of errors in
a different way (like warning the user about a problem through a message box). Exception
handlers can also be nested, meaning you can take care of problems within an inner block of
code that doesn’t affect outer blocks. Try accomplishing that in VB6 without convoluted
coding!
One of the truly new innovations in the .NET Framework is the concept of XML web
services. XML web services are objects that can be called over a standard HTTP protocol.
The object is serialized and deserialized into an XML format for transport, and then arrives
to your program as a standard .NET Framework object. This method of programming
allows developers to make services available on the Internet for other programmers to use,
either freely or against some type of payment model. The hope is that XML web services will
be the next generation of ActiveX controls, giving third-party developers an excellent way to
add value to developers by creating reusable objects that can be accessed over any Internet
connection.
Of course, this overview only scratches the surface of what makes VB .NET something
that gets you revved up. Microsoft took a step back and rethought the concept of the perfect
development tool, and the .NET platform is the result of that. Even after over a year of play-
ing with the language myself, I’m still learning about new classes in the .NET Framework
and when to use certain new development techniques or technologies.
Who Am I?
I was one of only two sophomores in my high school way back in 1982 who was offered a
computer class after the high school purchased six TRS-80s (“Trash-80s” we called them). I
attended the PC classes in junior and senior year, as well. Those were fun times, because the
4103c00.qxd 2/14/02 9:12 PM Page xviii
xviii Introduction
teachers were pretty much learning to navigate the PC world at the same time we were, and
we all kind of stumbled through those first years together.
Once I got my hands on software development in high school, I didn’t let go. I got my B.S.
in Information Systems at the Ohio State University (s’go Bucks!) and started work shortly
thereafter for an insurance organization. My job there was pretty interesting: All their data
was locked inside this legacy mainframe system (I couldn’t even tell you what system), and
one of their mainframe programmers wrote a custom query tool that extracted the data out
of the mainframe and into PC text files. They hired me out of school to act as a “business
analyst,” which basically meant that I would do ad hoc projects for people in the company
(spitting out mailing labels, summarizing data to back up research projects, and so on). My
programming tool at the time was FoxPro 2 by Fox Software (before Microsoft swallowed
them whole).
When I left the insurance company, I began a job-hopping journey (some my own doing,
some the doing of layoffs and mergers) through several industries, including finance, retail,
commercial software development (an antivirus package), and trucking. The main lesson that
I learned during these sojourns was that, even though I was pretty much doing the same
work (cranking out code) for all of these companies, I wasn’t really happy in any job unless I
personally found the industry interesting. Having had this epiphany, I set out to land a job in
the coolest industry I could think of, which brought me to my current (and, I hope, final)
position at the Cleveland Indians’ front office, where I’ve been happily designing in-house
systems for almost five years.
Not being satisfied with developing software a mere eight hours per day, I also write some
code in my spare time. I became enamored with the PC game industry and found myself
writing level-editing programs for games like Doom and Quake. I also wrote my first two
books for Sybex on constructing levels for games. My Quake level editor, qED, enjoyed
modest success as a shrink-wrapped, retail piece of software. I was doubly excited when I was
offered the chance by Sybex to write a book highlighting some of the power of VB .NET for
people just like myself—experienced Visual Basic programmers who want a crash course to
help tackle the learning curve associated with learning the new language.
If something ever does manage to get me away from my PC, it’s usually my wife and two
little girls or a baseball game.