Error l_ist|L:gjPending Checking Class Details | ^ Object Test Bench |~

Figure 2-18. The Class Details window

The Class Designer Toolbox (see Figure 2-19) allows you to insert new types into your project (and create relationships between these types) visually. (Be aware that you must have a class diagram as the active window to view this toolbox.) As you do so, the IDE automatically creates new VB 2008 type definitions in the background.

Figure 2-19. The Class Designer Toolbox

By way of example, drag a new class from the Class Designer Toolbox onto your Class Designer. Name this class Car in the resulting dialog box. Now, using the Class Details window, add a public String field named petName (see Figure 2-20).

Figure 2-20. Adding a field with the Class Details window

If you now look at the VB 2008 definition of the Car class (within the newly generated Car.vb file), you will see it has been updated accordingly (you will not find the following code comments, of course):

Public Class Car

' Public data is typically a bad idea, ' however it will simplify this example.

Public petName As String End Class

Now, add another new class to the designer named SportsCar. Next, select the Inheritance icon from the Class Designer Toolbox and click the SportsCar icon. Next, move the mouse cursor on top of the Car class icon and click the mouse again. If you performed these steps correctly, you have just derived the SportsCar class from Car (see Figure 2-21).

Car.vb*" CfassDtagraml.cd*' Object Browser Vs2008Example* Modulel.vb* [ StartPage

Was this article helpful?

0 0

Post a comment