Dela via


Object-Oriented Programming Sample

This solution demonstrates some of the object-oriented features of Visual Basic.

To get samples and instructions for installing them

  • Do one or more of the following:

    • On the Help menu, click Samples.

      The Readme displays information about samples.

    • Visit the Visual Studio 2008 Samples Web site. The most recent versions of samples are available there.

    • Locate samples on the computer on which Visual Studio is installed. By default, samples and a Readme file are installed in drive:\Program Files\Microsoft Visual Studio 9.0\Samples\lcid. For Express editions of Visual Studio, all samples are located online.

For more information, see Visual Studio Samples.

Security noteSecurity Note:

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To run this sample

  • Press F5.

Demonstrates

The project includes several class definitions. Customer is the base class, and contains only three properties. Four other classes are derived from the Customer class. Each inherits the properties of Customer, but adds another category of class member.

  • CustomerPropertySyntax is a modification of the Customer class that sets the AccountNumber property during construction. Once created, the AccountNumber cannot be changed.

  • CustomerWithConstructor is a modification of Customer that includes a constructor that sets all three properties during instantiation.

  • CustomerWithParameterizedProperty is a customization of Customer that adds a property that takes a parameter.

  • CustomerWithSharedMembers adds a shared property and a shared method to the Customer class.

See Also

Reference

Class Statement (Visual Basic)

Property Statement

ReadOnly (Visual Basic)

Shared (Visual Basic)

Other Resources

Understanding Classes