In addition to custom procedures, custom methods can also be created for existing objects by using public sub procedures or functions.
Custom methods can be created just as you created methods for your own objects, only you add a public sub procedure or function to the existing object. Now add a new method for the frmCarDetails form to see how this works.
Try It Out-Adding New Method for the frmCarDetails Form
From the Visual Basic Editor, select the frmCarDetails class module. Add the following method to the class:
Public Sub TestMethod() MsgBox "This is a test method added to an existing object" End Sub
From the frmCarDetails class module, add a new procedure called DemonstrateCustomMethods and type the me keyword followed by a period, as shown in Figure 4-16.
Figure 4-16
How It Works
First, you added the new method to the existing frmCarDetails form. Then, when you referred to frmCarDetails in code using the me keyword, you saw that the custom method you just added was in the drop-down list along with the custom property you just created and the original properties and methods. Just like properties, methods can be added to nearly any existing object.