Interface Interface1
Sub sub1(ByVal i As Integer)
End Interface
Interface Interface2
Inherits Interface1 ' Demonstrates interface inheritance.
Sub M1(ByVal y As Integer)
ReadOnly Property Num() As Integer
End Interface
下一个示例则实现上一示例中所定义的接口 Interface1:
Public Class ImplementationClass1
Implements Interface1
Sub Sub1(ByVal i As Integer) Implements Interface1.Sub1
' Place code here to implement this method.
End Sub
End Class
最后一个示例则实现 Interface2,包括自 Interface1 继承的方法:
Public Class ImplementationClass2
Implements Interface2
Dim INum As Integer = 0
Sub sub1(ByVal i As Integer) Implements Interface2.Sub1
' Place code here that implements this method.
End Sub
Sub M1(ByVal x As Integer) Implements Interface2.M1
' Place code here to implement this method.
End Sub
ReadOnly Property Num() As Integer Implements _
Interface2.Num
Get
Num = INum
End Get
End Property
End Class
Property 对象
表示给定对象的属性一般集合中的一个属性。
示例
Sub PropertyExample()
Dim Props As Properties
Dim PropObj As [Property]
Dim NameValPair As String
Props = DTE.Properties("Environment", "General")
MsgBox("Tools – Options – Environment – General Properties Count = " & Props.Count())
For Each PropObj In Props
NameValPair = NameValPair & (PropObj.Name & "Value = " & PropObj.Value & microsoft.VisualBasic.ControlChars.CrLf)
Next
MsgBox(NameValPair)
End Sub