Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
Function PBMain() As Long
Local Z As MyInterface 'z is object variable with interface MyInterface
Let Z = Class "MyClass" 'z is object of class "myclass". Interface is implied by object variable
? Str$(Z.x) 'uses Get
Z.MM 'uses exposed method MM
? Str$(Z.x) 'uses Get
Z.x = 14 'uses Set
? Str$(Z.x) 'uses Get
End Function
Class MyClass
'hidden stuff -----------------------------------------
Instance X As Long 'class variable
Class Method Create() : ? "Object created" : End Method 'startup method (optioanl)
Class Method Destroy() : ? "Object destroyed" : End Method 'end method (optional)
'exposed stuff -----------------------------------------
Interface MyInterface 'exported methods/variables
Inherit IUnknown 'inherit the base class
Property Get X As Long : Property = X : End Property 'Property Get parameters are optional
Property Set X (V As Long) : X = V : End Property 'Property Set requires at least 1 parameter
Method MM() : Incr X : End Method 'Exposed method
End Interface
End Class
'gbs_01343
'Date: 05-11-2013
http://www.garybeene.com/sw/gbsnippets.htm