资源说明:Introduction
Welcome to .NET and Visual Basic .NET.As you already know, .NET is a name for
a new strategy: a blueprint for building applications for the next decade. It’s actually even more
than that. It’s Microsoft’s commitment to remain at the top of a rapidly changing world and give
us the tools to address the needs of tomorrow’s computing. Visual Basic .NET is a language for
creating .NET applications, like many others. It also happens that Visual Basic is the easiest to
learn, most productive language (but you already know that).
Visual Basic .NET is released shortly after the tenth anniversary of the first version of VB.
The original language that changed the landscape of computing has lasted for 10 years and has
enabled more programmers to write Windowsapplication than any other language. Programmers
who invested in Visual Basic 10 years ago are in demand today. In the world of computing, how-
ever, things change very fast, including languages. At some point, they either die, or they evolve
into something new. Visual Basic was a language designed primarily for developing Windows
applications. It was a simple language, because it managed to hide many of the low-level details
of the operating system. Those who wanted to do more with Visual Basic had to resort to Win-
dows API. In a way, earlier versions of Visual Basic were ‘sandboxed’ to protect developers from
scary details.
Microsoft had to redesign Visual Basic. The old language just didn’t belong in the .NET pic-
ture (at least, it wouldn’t integrate very well into the picture). Visual Basic .NET is not VB7; it’s
a drastic departure from VB6, but a necessary departure. Visual Basic .NET was designed to take
us through the next decade of computing, and if you want to stay ahead, you will have to invest
the time and effort to learn it.
The most fundamental component of the .NET initiative is the .NET Framework, or simply
the Framework. You can think of the Framework as an enormous collection of functions for just
about any programming task. All drawing methods, for example, are part of the System.Drawing
class. To draw a rectangle, you call the DrawRectangle method, passing the appropriate argu-
ments. To create a new folder, you call the CreateDirectory method of the Directory class; to
retrieve the files in a folder, you call the GetFiles method of the same object. The Framework
contains all the functionality of the operating system and makes it available to your application
through numerous methods.
VB was such a success because it was a very simple language. You didn’t have to learn a lot
before you could start using the language. Being able to access the Framework’s objects means
that you’re no longer limited by the language. The new version of the language unlocks the full
potential of .NET; now there’s hardly anything you can do with another language but can’t do
2877c00.qxd 11/11/01 4:13 PM Page xxiii
INTRODUCTION
xxiv
with Visual Basic. This makes the language as powerful as any other language, but it also makes the
learning curve steeper. The good news is that, if you get started today, you’ll get a head start, which
may well last for another decade.
Who Should Read This Book?
You don’t need to know Visual Basic to read Mastering Visual Basic .NET,but you do need a basic
understanding of programming. You need to know the meaning of variables and functions and how
an If…Thenstructure works. This book is addressed to the typical programmer who wants to get the
most out of Visual Basic. It covers the topics I feel are of use to most VB programmers, and it does
so in depth. Visual Basic .NET is an extremely rich programming environment, and I’ve had to
choose between superficial coverage of many topics and in-depth coverage of fewer topics. To make
room for more topics, I have avoided including a lot of reference material and lengthy listings. For
example, you won’t find complete project listings or Form descriptions. I assume you can draw a few
controls on a Form and set their properties, and you don’t need long descriptions of the properties
of the control. I’m also assuming that you don’t want to read the trivial segments of each application.
Instead, the listings concentrate on the “meaty” part of the code: the procedures that explain the
topic at hand. If you want to see the complete listing, it’s all on the CD.
The topics covered in this book were chosen to provide a solid understanding of the principles
and techniques for developing applications with Visual Basic. Programming isn’t about new key-
words and functions. I chose the topics I felt every programmer should learn in order to master the
language. I was also motivated by my desire to present useful, practical examples. You will not find
all topics equally interesting or important. My hope is that everyone will find something interesting
and something of value to their daily work—whether it’s an application that maps the folders and
files of a drive to a TreeView control, an application that prints tabular data, or an application that
saves a collection of objects to a file.
Many books offer their readers long, numbered sequences of steps to accomplish something. Fol-
lowing instructions simplifies certain tasks, but programming isn’t about following instructions. It’s
about being creative; it’s about understanding principles and being able to apply the same techniques
in several practical situations. And the way to creatively exploit the power of a language such as
Visual Basic .NET is to understand its principles and its programming model.
In many cases, I provide a detailed, step-by-step procedure that will help you accomplish a task,
such as designing a menu. But not all tasks are as simple as designing menus. I explain why things
must be done in a certain way, and I present alternatives and try to connect new topics to those
explained earlier in the book. In several chapters, I expand on applications developed in earlier chap-
ters. Associating new knowledge to something you have already mastered provides positive feedback
and a deeper understanding of the language.
This book isn’t about the hottest features of the language; it’s about solid programming tech-
niques and practical examples. For example, I’m not going to show you how to write multithreaded
applications. The real challenge with multithreaded applications is their debugging, which requires
substantial experience. Once you master the basics of programming Windowsapplications with
Visual Basic .NET and you feel comfortable with the more advanced examples of the book, you will
find it easy to catch up with the topics that aren’t discussed.
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。