9,2 Tạo một lớp mà thực hiện các giao diện Bạn Defined Bây giờ bạn đã định nghĩa giao diện nào của lớp học của bạn, bạn cần phải tạo ra một lớp mà sẽ thực hiện mà giao diện, cùng với tất cả các phương pháp và tính chất của nó. | Create a Class That Implements the Interface You Defined Now that you have defined the public interface of your class you need to create a class that will implement that interface along with all of its methods and properties. The place to start is with the properties of your class. You ll also need to create some code to test your class so you ll need to create a form that interacts with the instances of the class. Technique This section uses a form with text boxes that mirror the properties of the CCustomer class. Visual Basic .NET allows you to have classes and forms within the same .vb file so this section will have both in one file to make editing and debugging easier. After setting up the form you need to implement the class properties. If you have worked with Property statements before this technique will be old hat although the syntax will be new . If you have not worked with properties and classes you will need the following A private variable for each property to store class data Code to modify and return that data Steps 1. Create a Windows Form and name it frmHowTo9_2. Then place text boxes for each of the properties of the class naming the text boxes with the property name prefaced by txt. For example the postal code text box should be named txtPostalCode. Next add command buttons called cmdDelete cmdSave cmdRetrieve and cmdNew. Finally add a RichTextBox control called rtbToString to contain the output of the ToString method. This enables you to see how the Form maps to the data of the class. See Figure Figure . Arrange the controls on the form you created to look like this form. 2. Add a class declaration block to frmHowTo9_2 and name the class CCustomer. After the line Public Class CCustomer type Implements ICustomer. This tells Visual Basic that the CCustomer class includes all of the properties and methods of the ICustomer interface as shown in Listing . Listing The Empty Customer Class Public Class CCustomer .