Edit
'Edit implementation
End Sub
Sub DropDown() Implements IDropList.DropDown
'Drop down implementation
End Sub
Public Sub Paint() Implements IDropList.Paint
'Paint implementation
End Sub
End Class
In this example, the ComboBox class implements both IEditBox and IDropList, and each
inherits Paint() from IUIControl. Since ComboBox implements both of these interfaces, it must
implement all the methods in them, plus the Paint method they inherit. Note that although
both IEditBox and IDropList inherit Paint() from IUIControl, ComboBox only needs to implement
it once. It also could have used either
Sub Paint() Implements IEditBox.Paint
or
Sub Paint() Implements IUIControl.Paint
and, as ComboBox has only one implementation of the Paint method, if you were to cast a
ComboBox instance into either an IEditBox or IDropList variable, then calling Paint() on
either variable would call the same implementation.
Hiding Interface Members
Sometimes??”albeit rarely??”you need to declare a method in an interface that hides a method in
an inherited interface. You use the Overloads modifier to do so. For example, if IDropList needs
its own version of Paint(), you??™ll have to change both IDropList and ComboBox as follows:
Public Interface IUIControl
Sub Paint()
End Interface
CHAPTER 6 n INTERFACES 102
Public Interface IEditBox
Inherits IUIControl
Sub Edit()
End Interface
Public Interface IDropList
Inherits IUIControl
Overloads Sub Paint()
Sub DropDown()
End Interface
Public Class ComboBox
Implements IEditBox, IDropList
Sub Edit() Implements IEditBox.
Pages:
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193