|
-
Jan 7th, 2003, 06:59 AM
#1
Thread Starter
Fanatic Member
Urgent - Interface doesn't implement class
I have a Client set up in one VB app to use a object being run in a separate VB app.
The client passes execution to the Interface, but the Class is never accessed. Could someone tell me why?
Thanks in advance.
This is the client code
Code:
Option Explicit
Private Sub Command1_Click()
Dim objComp As Object
Set objComp = CreateObject("TSTestComp.IComp")
Debug.Print objComp.Name
End Sub
This is the interface code being run separately called IComp. The instancing is set to MultiUse.
Code:
Property Get Name() As String
'
End Property
Property Let Name(ByVal vNewValue As String)
'
End Property
Property Get Version() As Variant
'
End Property
Property Let Version(ByVal vNewValue As Variant)
'
End Property
This is the class code being run separately called CComp.The instancing is set to PublicNotCreatable.
Code:
Implements IComp
Private Name As String
Private Property Let IComp_Name(ByVal RHS As String)
Debug.Print "Hello World"
End Property
Private Property Get IComp_Name() As String
Debug.Print "Hello World"
End Property
Private Property Let IComp_Version(ByVal RHS As Variant)
Debug.Print "Hello World"
End Property
Private Property Get IComp_Version() As Variant
Debug.Print "Hello World"
End Property
Mindcrime : )
ICQ 24003332
VB 5.0, VB 6.0 SP5, COM, DCOM, VB.NET Beta 2, Oracle 8
-
Jan 7th, 2003, 12:42 PM
#2
Set objComp = CreateObject("TSTestComp.IComp")
Because you re setting a reference to the interface, not the class that implements it. look at your CreateObject line ^^^
-
Jan 8th, 2003, 03:48 AM
#3
Thread Starter
Fanatic Member
Cander, thanks for the reply.
I have hardly touched on COM before and I am being asked to do something in VB, which a C++ coder knows they can do (in C++).
I could use referenced objects and code as follows:
Code:
Dim objCComp as CComp
Dim objIComp as Icomp
Set objCComp = new CComp
Set objIComp = objCComp
This would give me what I am after when using CreateObject. I don't know if it is possible.
At the end of the day, the end application has to be as dynamic as possible.
Regards
Mindcrime : )
ICQ 24003332
VB 5.0, VB 6.0 SP5, COM, DCOM, VB.NET Beta 2, Oracle 8
-
Jan 8th, 2003, 11:33 AM
#4
But see there is no reason to do that. Just set you reference to the class the implements the interface. Since the class implements that interface, it's Type is considered to be that interface. there is no reason to create an instance of an interface, because interfaces have no code to run.
-
Jan 8th, 2003, 12:00 PM
#5
Just read your other post. Makes more sense now as to what you are doing. So nevermind the last thing I said. I wasnt taking into account the late binding Object.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|