Chapter 16: Inheriting Forms and Creating Base Classes


Chapter 16

Inheriting Forms and Creating Base Classes

After completing this chapter, you will be able to:

  • Use the Inheritance Picker to incorporate existing forms in your projects.

  • Create your own base classes with custom properties and methods.

  • Derive new classes from base classes by using the Inherits statement.

An important skill for virtually all professional software developers today is the ability to understand and utilize object-oriented programming (OOP) techniques. Although Microsoft Visual Basic 6 offers several object-oriented programming features, experts say that it lags behind the “true” OOP languages, such as Microsoft Visual C++, because it lacks inheritance, a mechanism that allows one class to acquire the interface and behavior characteristics of another class.

Beginning with Microsoft Visual Basic .NET 2002, the Visual Basic language and IDE have supported inheritance, which means that you can build one form in the development environment and pass its characteristics and functionality on to other forms. In addition, you can build your own classes and inherit properties, methods, and events from them.

In this chapter, you'll experiment with both types of inheritance. You'll learn how to integrate existing forms into your projects by using the Inheritance Picker dialog box that is part of Microsoft Visual Studio 2005, and you'll learn how to create your own classes and derive new ones from them by using the Inherits statement. With these skills, you'll be able to utilize many of the forms and coding routines you've already developed, making Visual Basic programming a faster and more flexible endeavor. These improvements will help you design compelling user interfaces rapidly and will extend the work that you have done in other programming projects.

Upgrade Notes: Migrating Visual Basic 6 Code to Visual Basic 2005

If you're experienced with Visual Basic 6, you'll notice some new features in Microsoft Visual Basic 2005, including the following:

  • You can inherit forms within the Visual Studio IDE by using the Inheritance Picker dialog box.

  • Classes are now defined between the Public Class and End Class keywords.

  • Several user-defined classes can now be stored in a single source file. (In Visual Basic 6, each new class has to be stored in its own file.)

  • You can add properties to classes by using a new syntax, first introduced in Visual Basic .NET 2002.

  • The Inherits keyword allows a new derived class to inherit the interface and behaviors of an existing class.



Microsoft Visual Basic 2005 Step by Step
Microsoft Visual Basic 2005 Step by Step (Step by Step (Microsoft))
ISBN: B003E7EV06
EAN: N/A
Year: 2003
Pages: 168

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net