Code:
Property Get SQL() As ImportObject_ISQL Property = Me End Property
Code:
Override Property Get SQL() As UNIT4AGRESSO_ISQL Property = Me End Property
I know doable but so far not with strong typed coding techniques i guess.
Property Get SQL() As ImportObject_ISQL Property = Me End Property
Override Property Get SQL() As UNIT4AGRESSO_ISQL Property = Me End Property
[color=#0000FF]Class[/color] clsImportObject [color=#0000FF]Interface[/color] iImportObject: [color=#0000FF]Inherit[/color] [color=#0000FF]IUnknown[/color] [color=#0000FF]Method[/color] GetImportName() [color=#0000FF]As[/color] [color=#0000FF]String[/color] [color=#0000FF]Method[/color] = "Unknown" [color=#0000FF]End[/color] [color=#0000FF]Method[/color] [color=#0000FF]End[/color] [color=#0000FF]Interface[/color] [color=#0000FF]End[/color] [color=#0000FF]Class[/color] [color=#0000FF]Class[/color] clsUNIT4AGRESSO [color=#0000FF]Interface[/color] UNIT4AGRESSO_iImportObject: [color=#0000FF]Inherit[/color] clsImportObject, iImportObject Override [color=#0000FF]Method[/color] GetImportName() [color=#0000FF]As[/color] [color=#0000FF]String[/color] [color=#0000FF]Method[/color] = "UNIT4AGRESSO" [color=#0000FF]End[/color] [color=#0000FF]Method[/color] [color=#0000FF]End[/color] [color=#0000FF]Interface[/color] [color=#0000FF]End[/color] [color=#0000FF]Class[/color] [color=#0000FF]Macro[/color] Import_CreateObject(p1, p2) [color=#0000FF]MacroTemp[/color] i2 [color=#0000FF]Dim[/color] i2 [color=#0000FF]As[/color] p2 i2 = [color=#0000FF]Class[/color] p1 i = [color=#0000FF]Nothing[/color] [color=#0000FF]If[/color] [color=#0000FF]IsObject[/color]( i2 ) [color=#0000FF]Then[/color] [color=#0000FF]Poke[/color] [color=#0000FF]Dword[/color], [color=#0000FF]VarPtr[/color]( i ), [color=#0000FF]ObjPtr[/color]( i2 ) i.Addref() i2 = [color=#0000FF]Nothing[/color] [color=#0000FF]End[/color] [color=#0000FF]If[/color] [color=#0000FF]End[/color] [color=#0000FF]Macro[/color] [color=#0000FF]Function[/color] Test( [color=#0000FF]ByVal[/color] nIndex [color=#0000FF]As[/color] [color=#0000FF]Long[/color] ) [color=#0000FF]As[/color] [color=#0000FF]Long[/color] [color=#0000FF]Local[/color] i [color=#0000FF]As[/color] iImportObject [color=#0000FF]Select[/color] [color=#0000FF]Case[/color] nIndex [color=#0000FF]Case[/color] 0: i = [color=#0000FF]Class[/color] "clsImportObject" [color=#0000FF]Case[/color] 1: Import_CreateObject( "clsUNIT4AGRESSO", UNIT4AGRESSO_iImportObject ) [color=#0000FF]Case[/color] [color=#0000FF]Else[/color] [color=#0000FF]Exit[/color] [color=#0000FF]Function[/color] [color=#0000FF]End[/color] [color=#0000FF]Select[/color] [color=#0000FF]If[/color] [color=#0000FF]IsNothing[/color]( i ) [color=#0000FF]Then[/color] [color=#0000FF]Exit[/color] [color=#0000FF]Function[/color] [color=#0000FF]MsgBox[/color] i.GetImportName() [color=#007F00]' More i... calls here....[/color] [color=#0000FF]End[/color] [color=#0000FF]Function[/color]
Class Class1 Class Method Destroy MsgBox "Destroy Class1" End Method Interface Class1_Interface1: Inherit IUnknown Method TEST() As String Method = "1234" End Method End Interface End Class Class Class2 Class Method Destroy MsgBox "Destroy Class2" End Method Interface Class2_Interface1: Inherit Class1, Class1_Interface1 Override Method TEST() As String Method = "2345" End Method End Interface End Class Function Test() As Long Local i1 As Class1_Interface1 Local i2 As Class2_Interface1 i2 = Class "Class2" [B]Poke Dword, VarPtr( i1 ), ObjPtr( i2 ) i1.addref()[/B] MsgBox i1.TEST() & ", " & i2.TEST() End Function
#Compile Exe #Dim All ' Note: These guids taken from help file and not gauranteed to be unique ' for demo purposes only $cPerson = Guid$("{00000099-0000-0000-0000-000000000008}") $iPerson = Guid$("{00000099-0000-0000-0000-000000000009}") $cEmployee = Guid$("{00000099-0000-0000-0000-000000000010}") $iEmployee = Guid$("{00000099-0000-0000-0000-000000000009}") ' NOTE same as iPerson Class cPerson $cPerson Instance sLastName As String Instance sFirstName As String Instance sAddress As String Instance sCity As String Instance sState As String Instance sZip As String Interface iPerson $iPerson Inherit IUnknown Property Get Lastname () As String Property = sLastname End Property Property Set Lastname(ByVal lName As String) sLastname = lname End Property Property Get Firstname() As String Property = sFirstName End Property Property Set firstName(ByVal fName As String) sFirstname = fname End Property Property Get Address() As String Property = sAddress End Property Property Set Address(ByVal sAddr As String) sAddress = sAddr End Property Property Get City() As String Property = sCity End Property Property Set City (ByVal sNewCity As String) sCity = sNewCity End Property Property Get State() As String Property = sState End Property Property Set State(ByVal sNewState As String) sState = sNewState End Property Property Get Zip() As String Property = sZip End Property Property Set Zip(ByVal sNewZip As String) sZip = sNewZip End Property Method FullName() As String Method = sFirstname + " " + sLastname End Method Method LastNameCommaFirst() As String Method = sLastname + ", " + sFirstname End Method Method AddressLabel() As String Method = me.FullName + $CrLf + me.Address + $CrLf + me.City + ", " + me.State + " " + me.Zip End Method End Interface End Class Class cEmployee $cEmployee Instance sTitle As String Instance sSalary As String Interface iEmployee $iEmployee Inherit cPerson, iPerson Override Method AddressLabel() As String Method = Me.Title + " " + me.FullName + $CrLf + me.Address + $CrLf + me.City + ", " + me.State + " " + me.Zip End Method Property Get Title () As String Property = sTitle End Property Property Set Title (ByVal newTitle As String) sTitle = newTitle End Property End Interface End Class Function printAddress (obj As iPerson) As String Function = obj.addresslabel End Function Function PBMain () As Long Dim persons(10) As iPerson Local i As Long Local person As iPerson Local person2 As iEmployee For i = 0 To 10 If i Mod 2 = 0 Then person = Class "cPerson" person.firstname = "John" person.lastname = "Smith" person.address = "123 Main Street" person.city = "Anytown" person.state = "Anywhere" person.zip = "12345" persons(i) = person Else person2 = Class "cEmployee" person2.Title = "President" person2.firstname = "Jane" person2.lastname = "Doe" person2.address = "123 Main Street" person2.city = "Anytown" person2.state = "Anywhere" person2.zip = "12345" persons(i) = person2 End If Next i For i = 0 To 10 MsgBox printaddress(persons(i)) Next i ' MsgBox person.FullName & $CrLf & person2.fullname ' MsgBox person.LastnameCommaFirst & $CrLf & person2.LastnameCommaFirst ' MsgBox person.addresslabel End Function
Local i As Class1_Interface1 i = Class "Class2"
Local i As Class1_Interface1 i = Class "Class1"
Local i As Class2_Interface1 i = Class "Class2"
Class Class1 Interface Class1_Interface1: Inherit IUnknown Method TEST() As String Method = "1234" End Method End Interface End Class Class Class2 Interface Class2_Interface1: Inherit Class1, Class1_Interface1 Override Method TEST() As String Method = "2345" End Method End Interface End Class Function Test() As Long Local i1 As Class1_Interface1 Local i2 As Class2_Interface1 i1 = Class "Class1" i2 = Class "Class2" MsgBox i1.TEST() & ", " & i2.TEST() End Function
Function Test() As Long Local i2 As Class2_Interface1 Local i As Class1_Interface1 i2 = Class "Class2" i = i2 MsgBox i.TEST() End Function
Function Test() As Long Local i As Class1_Interface1 i = Class "Class2" MsgBox i.TEST() End Function
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Leave a comment: