Microsoft Visual Basic 2010 Step by Step eBook

(Tina Meador) #1

408 Part III Designing the User Interface


Your form looks similar to this:


  1. Click the Display Record button.


Your program stores the first name and last name values in property settings and uses
the Age method to calculate the new employee’s current age. A message box displays the
result, as shown here:


  1. Click OK to close the message box, and then experiment with a few different date


(^) values, clicking Display Record each time you change the Birth Date field.



  1. When you’re finished experimenting with your new class, click the Close button on
    the form.
    The development environment returns.


One Step Further: Inheriting a Base Class


As promised at the beginning of this chapter, I have one more trick to show you regarding
user-defined classes and inheritance. Just as forms can inherit form classes, they can also
inherit classes that you’ve defined by using the Add Class command and a class module.
The mechanism for inheriting a base (parent) class is to use the Inherits statement to
include the previously defined class in a new class. You can then add additional properties
Free download pdf