27-03-2014, 12:47 PM
Programming Visual Basic .NET
Introduction
With its release for the .NET platform, the Visual Basic language has undergone dramatic changes.
For example:
The language itself is now fully object-oriented.
Applications and components written in Visual Basic .NET have full access to the .NET
Framework, an extensive class library that provides system and application services.
All applications developed using Visual Basic .NET run within a managed runtime environment,
the .NET common language runtime.
In this introduction, I briefly discuss these changes and other changes before showing you three very
simple, but complete, Visual Basic .NET applications.
What Is the Microsoft .NET Framework?
The .NET Framework encompasses the following:
•A new way to expose operating system and other APIs. For years, the set of Windows
functionality that was available to developers and the way that functionality was invoked were
dependent on the language environment being used. For example, the Windows operating
system provides the ability to create windows (obviously). Yet, the way this feature was
invoked from a C++ program was dramatically different from the way it was invoked from a
Visual Basic program. With .NET, the way that operating system services are invoked is
uniform across all languages (including code embedded in ASP.NET pages).
This portion of .NET is commonly referred to as the .NET Framework class library.
•A new infrastructure for managing application execution. To provide a number of sophisticated
new operating-system services—including code-level security, cross-language class
inheritance, cross-language type compatibility, and hardware and operating-system
independence, among others—Microsoft developed a new runtime environment known as the
Common Language Runtime (CLR). The CLR includes the Common Type System (CTS) for
cross-language type compatibility and the Common Language Specification (CLS) for
ensuring that third-party libraries can be used from all .NET-enabled languages.
To support hardware and operating-system independence, Microsoft developed the Microsoft
Intermediate Language (MSIL, or just IL). IL is a CPU-independent machine language-style
instruction set into which .NET Framework programs are compiled. IL programs are compiled
to the actual machine language on the target platform prior to execution (known as just-in-time,or JIT, compiling). IL is never interpreted.
What Is Visual Basic .NET?
Visual Basic .NET is the next generation of Visual Basic, but it is also a significant departure from
previous generations. Experienced Visual Basic 6 developers will feel comfortable with Visual
Basic .NET code and will recognize most of its constructs. However, Microsoft has made some
changes to make Visual Basic .NET a better language and an equal player in the .NET world. These
include such additions as a Class keyword for defining classes and an Inherits keyword for object
inheritance, among others. Visual Basic 6 code can't be compiled by the Visual Basic .NET compiler
without significant modification. The good news is that Microsoft has provided a migration tool to
handle the task (mostly, anyway). Code migration is explained in Appendix A. The Visual Basic .NET
language itself is detailed in Chapter 2.