Edit
'Edit implementation
End Sub
Sub DropDown() Implements IDropList.DropDown
'Drop down implementation
End Sub
Public Sub Paint() Implements IEditBox.Paint
'Paint implementation
End Sub
Public Sub DropPaint() Implements IDropList.Paint
'Paint DropList
End Sub
End Class
In this example, Overloads Sub Paint() has been added to IDropList, allowing it to hide
the Paint method inherited from IUIControl. Next, the new Paint() is implemented via the
DropPaint method in ComboBox. IUIControl.Paint() must still be implemented because it??™s
part of IEditBox; either IUIControl or IEditBox could have been used as the qualifier.
Implementing Interfaces in Structures
While implementing interfaces in a class is most typical, it is possible to implement them in
structures as well. Let??™s define two structures to represent integers and doubles and provide
them with an interface that guarantees you can raise them to an integer power:
Public Interface IPowerable
Function RaiseToN(ByVal n As Integer)
End Interface
CHAPTER 6 n INTERFACES 103
Public Structure AnInteger
Implements IPowerable
Public i As Integer
Public Sub New(ByVal value As Integer)
Me.i = value
End Sub
Public Function RaiseToN(ByVal n As Integer) As Object _
Implements IPowerable.
Pages:
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194