VB.Net Programming with the Public Beta

VB.Net Programming with the Public Beta

by Billy Hollis, Rockford Lhotka

Paperback

$29.23 $34.99 Save 16% Current price is $29.23, Original price is $34.99. You Save 16%.

Overview

This book is for existing developers, with a background in Visual Basic, ASP, or VBScript, who want a summary of the differences between VB6 and VB.NET, as well as information on migration issues. This book was written on the public beta release and while we can't guarantee that the final version will be identical, you can be sure that almost all of the concepts, examples, and explanations will still be available for the final release.

Product Details

ISBN-13: 9781861004918
Publisher: Wrox Press, Inc.
Publication date: 02/01/2001
Pages: 433
Product dimensions: 7.26(w) x 9.23(h) x 0.98(d)

About the Author

Billy Hollis has also written many articles, reviews, and columns, appearing in such publications as the Visual Basic Programmers Journal, Unisphere, and Computer User Magazine. He is a frequent speaker at industry events such as the Visual Basic Insiders Technical Summit (VBITS) and Comdex. He presented two sessions at VBITS New York in June 2000 on Getting Ready for Web Forms and A COM Component for Browser Independence. His session at VBITS 99 in Chicago was the highest rated session at the conference. His most recent presentation was at the Wrox conference in Las Vegas (September 2000) on What's new in VB.NET. He is also currently writing the introductory chapter for the Wrox book (in production) previewing Microsoft.NET.

Billy is the Microsoft MSDN Regional Director for Nashville, Tennessee, and collaborates with Microsoft to put on Developer Days in Nashville. He is considered a Subject Matter Expert at Microsoft, and is on the content committee to develop the content for Developers Days 2000.

Rockford Lhotka is the author of Professional Visual Basic 6 Distributed Objects and Visual Basic 6 Business Objects both published by Wrox Press and is a contributing author for Visual Basic Programmers Journal and DevX. He has resented at numerous conferences including Microsoft Tech Ed and VBITS. He has over 14 years experience in software development and has worked on many projects in various roles, including software architecture, design and development, network administration and project management. Rockford is the Principal Technology Evangelist for Magenic Technologies, one of the nation's premiere Microsoft Certified Solution Providers dedicated to solving today's most challenging business problems using 100% Microsoft tools and technology.

Read an Excerpt

5: New Object-Oriented Capabilities of VB.NET

When Visual Basic 4.0 was released, it introduced a whole new era of programming for VB. Object-oriented (OO) programming was finally a possibility. Unfortunately, few OO features were included in the VB language at that point. Most notably lacking were inheritance capabilities, one of the key defining criteria for any OO language. VB was also missing a large number of secondary features such as method overloading and overriding, and constructors.

With VB.NET, the VB language finally completes the transition to a fully OO language. We now have full inheritance, along with all of the associated features we'd expect.

While it certainly remains possible to create applications that make no more use of objects than we did in VB3, these new capabilities are quite pervasive and so at least some basic understanding is required to become fully proficient in the use of VB.NET.

Generally speaking, a language is considered to be OO if it supports four main features:

  • Abstraction. VB has supported abstraction since VB4. Abstraction is merely the ability of a language to create "black box" code – to take a concept and create an abstract representation of that concept within a program. A Customer object, for instance, is an abstract representation of a real-world customer. A Recordset object is an abstract representation of a set of data.

  • Encapsulation. This has also been with us since version 4.0. It's the concept of a separation between interface and implementation. The idea is that we can create an interface (Public methods in a class) and, as long as that interface remains consistent, the application can interact with our objects. This remains true even if we entirely rewrite the code within a given method – thus the interface is independent of the implementation.

    Encapsulation allows us to hide the internal implementation details of a class. For example, the algorithm we use to compute Pi might be proprietary. We can expose a simple API to the end user, but we hide all of the logic used for our algorithm by encapsulating it within our class.

  • Polymorphism. Likewise, polymorphism was introduced with VB4. Polymorphism is reflected in the ability to write one routine that can operate on objects from more than one class – treating different objects from different classes in exactly the same way. For instance, if both Customer and Vendor objects have a Name property, and we can write a routine that calls the Name property regardless of whether we're using a Customer or Vendor object, then we have polymorphism.

    VB, in fact, supports polymorphism in two ways – through late binding (much like Smalltalk, a classic example of a true OO language) and through the implementation of multiple interfaces. This flexibility is very powerful and is preserved within VB.NET.

  • Inheritance. VB.NET is the first version of VB that supports inheritance. Inheritance is the idea that a class can gain the pre-existing interface and behaviors of an existing class. This is done by inheriting these behaviors from the existing class through a process known as subclassing. With the introduction of full inheritance, VB is now a fully OO language by any reasonable definition.

In this chapter we'll discuss all these new features and what they mean to us as VB developers.

Merger of Object- and Component-Oriented Concepts

Since version 4.0, VB has provided us with the ability not only to create objects, but also COM components. In fact, VB's ability to create objects, and the way VB objects worked, was very closely tied to COM and the way objects worked within and between COM components.

In COM, components are pre-compiled binary entities – typically a DLL, EXE or OCX file. Each component contains one or more classes that can be used by client applications. In VB6 we could create ActiveX EXE, ActiveX DLL or user control (OCX) projects – thus creating COM components. Even when we weren't creating these project types, the way VB6 allowed us to create and work with objects was defined by how objects were created within COM components.

It comes as no surprise then that VB.NET is very closely tied to the way .NET handles objects and the way objects work within and between .NET assemblies or components. This represents a pretty substantial change for VB, however, since .NET is substantially more advanced in terms of objects and components as compared to COM.

With COM, objects and components were interrelated, but the marriage of the two was far from seamless. In .NET on the other hand, OO and component-oriented concepts (as defined earlier) are very closely related in ways that we could only dream of in the COM environment.

In .NET we retain the component-oriented features we are used to:

  • Component-level scoping via the Friend keyword
  • Ability to implement interfaces with the Implements keyword
Component-level scoping allows us to create classes or methods that are available to all the other code in our component – but not to code outside our component. We'll discuss this in more detail later, but basically it is a level of scoping that sits between Private and Public – and is accessed via the Friend keyword.

Implementing interfaces via the Implements keyword allows each of our classes to have several different "identities" – each with its own interface. This is a powerful technique that is used widely within both COM and .NET, and is something we'll discuss in more detail later. In addition to these existing features, with .NET we also gain some strong capabilities – most importantly inheritance and the Inherits keyword.

VB.NET benefits from this new, closer relationship between objects and components – making both types of concept central to the language and to the way we develop applications.

Let's walk through the OO features in VB.NET.

VB.NET OO Implementation

VB.NET not only provides us with new OO features, but it also changes the way we implement some of the features we are used to from VB6. As we go through these features we'll cover both the new capabilities and also explore the changes to existing features.

Creating Classes

When building classes in previous versions of VB, each class got its own file. While simple, this solution could cause a larger OO project to have many files. VB.NET allows us to put more than one class in a single source file. While we don't have to take this approach, it can be nice since we can reduce the overall number of files in a project – possibly making it more maintainable.

Additionally, VB.NET provides support for the concept of .NET namespaces, as we discussed in Chapters 2 and 3. There are also changes to the syntax used to create Property methods, and we can overload methods in our classes. We'll look at all these features shortly. First though, let’s look at how we add a class to a project.

Adding a class in VB.NET is similar to adding a class in VB6. In order to do this we need to create a new Windows Application project and choose the Project | Add Class menu option to bring up the Add New Item dialog...

Table of Contents

Introduction
Chapter 1 Getting Started
Chapter 2 Introduction to the .NET Framework
Chapter 3 New IDE and Language Features of VB.NET
Chapter 4 New Windows UI Capabilities of VB.NET
Chapter 5 New 0bject-0riented Capabilities of VB.NET
Chapter 6 New Web Capabilities of Visual Basic.NET
Chapter 7 Data Access in Visual Basic.NET
Chapter 8 Advanced Topics
Chapter 9 Interoperability and Migration
Chapter 10 More Development Examples in Visual Basic.NET
Chapter 11 Wrap Up
A Guide to the Index
Index

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews

VB.Net Programming with the Public Beta 2 out of 5 based on 0 ratings. 1 reviews.
Guest More than 1 year ago
not very much how to, and not to many examples. Reads like a badly organized newpaper story about VB.net.