www.pudn.com > vb-Polymorphic-interface.rar > PolyInterface.cls, change:2013-02-16,size:2698b


VERSION 1.0 CLASS 
BEGIN 
  MultiUse = -1  'True 
  Persistable = 0  'NotPersistable 
  DataBindingBehavior = 0  'vbNone 
  DataSourceBehavior  = 0  'vbNone 
  MTSTransactionMode  = 0  'NotAnMTSObject 
END 
Attribute VB_Name = "PolyInterface" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = True 
Attribute VB_PredeclaredId = False 
Attribute VB_Exposed = True 
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes" 
Attribute VB_Ext_KEY = "Top_Level" ,"Yes" 
'实现ActiveX接口 
'------------------ 
Option Explicit 
 
'抽象类实现多重接口(属性和方法) 
Implements AbstractClass   '类模块中实现接口 
Private x As New AbstractClass 
Private mCV As Variant 
 
'实体类实现多重接口(属性和方法) 
Implements ClsVolumeCheck  '类模块需要为每一个属性和方法实现接口 
Private clsVC As New ClsVolumeCheck 
Private mVCP As Variant 
 
'抽象类实现多重接口(属性和方法)====================== 
'为空接口模块编写实现代码: 
'AbstractClass的currentVolume属性的实现代码 
 
Private Property Let AbstractClass_currentVolume(ByVal RHS As Variant) 
    mCV = RHS 
End Property 
 
Private Property Get AbstractClass_currentVolume() As Variant 
    AbstractClass_currentVolume = mCV 
End Property 
 
'AbstractClass的VolumeCheck方法的实现代码 
 
Private Sub AbstractClass_VolumeCheck() 
 
  If AbstractClass_currentVolume < 200 Or AbstractClass_currentVolume > 240 Then 
     MsgBox ("VolumeWarn(220V)......") 
   End If 
    
End Sub 
 
'编写调用接口的Public过程和方法 
Public Sub Volume(v As Integer) 
    AbstractClass_currentVolume = v 
    Call AbstractClass_VolumeCheck 
End Sub 
 
'抽象类实现多重接口(属性和方法)====================== 
 
 
 
'实体类类实现多重接口(属性和方法)====================== 
 
 
 
 
Private Property Let ClsVolumeCheck_CurVolume(ByVal RHS As Variant) 
 
End Property 
 
Private Property Get ClsVolumeCheck_CurVolume() As Variant 
 
End Property 
 
Private Sub ClsVolumeCheck_VolumeCheck() 
   Call clsVC.VolumeCheck '调用ClsVolumeCheck类的VolumeCheck方法 
End Sub 
 
Public Sub OldCode(VV As Integer) '使用原接口代码 
    ClsVolumeCheck_CurVolume = VV 
    Call ClsVolumeCheck_VolumeCheck '将执行ClsVolumeCheck类中VolumeCheck方法代码 
End Sub 
 
Public Sub AddCode(VV As Integer) '在原接口代码前后执行一些其他代码 
    ClsVolumeCheck_CurVolume = VV 
    MsgBox ("Added CODE") '用户可以增加任意其他代码 
    Call ClsVolumeCheck_VolumeCheck '将执行ClsVolumeCheck类中VolumeCheck方法代码 
    MsgBox ("Added CODE") '用户可以增加任意其他代码 
End Sub 
 
Public Sub NewCode(VV As Integer) '不使用原接口代码而使用新代码 
   ClsVolumeCheck_CurVolume = VV 
   MsgBox ("New CODE") '用户可以增加任意其他代码 
End Sub 
 
 
'实体类类实现多重接口(属性和方法)======================